Author: cool2000 | Posted on: 10/18/2009 4:54:20 PM | Views : 303

I've got the following code:
DirectoryInfo DI = new DirectoryInfo("PathToTheDirectory"); List<string> fileNames = new List<string>(); foreach(FileInfo FI in DI.GetFiles()) { fileNames.Add(FI.Name); } foreach(string fn in fileNames) { FileInfo FI = new FileInfo("PathToTheDirectory/" + fn); FI.Delete(); } DI.Delete();
I would think that after the foreach(string fn in fileNames), the directory referred to by DI would be empty. I even checked the file system and it really has no contents anymore but I am still getting that "directory is not empty" error.
I know that image files used to be in the folder (on the server). There might be that thumbs.db file that I can't seem to access from DirectoryInfo.GetFiles() then? Could that even be the issue? If so, how do I access that file (or any other hidden file) and finally delete it? Go to the complete details ...