If this were VB I'd just be sloppy and throw an Error Resume Next, lolling all the way to the bank, but obviously I don't have that option in C#. The problem is that using try/catch isn't returning any Exceptions, so I don't know what else to do. Can anyone suggest how I can handle this?
Heres's the code I'm using:
Expand|Select|Wrap|Line Numbers
- private void searchFiles(string drive, string extension, string savedFile)
- {
- FileInfo saveList = new FileInfo(savedFile);
- StreamWriter w = saveList.CreateText();
- DirectoryInfo di = new DirectoryInfo(drive);
- FileInfo[] lstFiles = di.GetFiles(extension, SearchOption.AllDirectories);
- foreach (FileInfo fi in lstFiles)
- {
- w.WriteLine(fi.FullName);
- }
- w.Close();
- }