/*
Author: Jiangong SUN
*/
I will introduce the recursive method in implementing the iterations of all the directories and files in a directory.
Here it is:
Because there exists recursive call of method "IterateFoldersAndFiles". "using" can't be used.
using(StreamWriter sw = new StreamWrite("D:\\AllFiles.txt")){}
In this example, the code can be written from:
StreamWriter sw = new StreamWriter("D:\\Allfiles.txt");
to:
StreamWriter sw = new StreamWriter(@"D:\Allfiles.txt");
because with "@" sign, the string can be interpreted normally. See references for more information.
Ok, here is the implementation. I hope you can find useful information here. Enjoy coding!
reference:
http://stackoverflow.com/questions/929276/how-to-recursively-list-all-the-files-in-a-directory-in-c
http://support.microsoft.com/kb/303974
http://www.yoda.arachsys.com/csharp/strings.html