Deleting a set of file
Hi, I want to delete a set of files but in an efficient way.
I have an array of string called filesToUse that contains the list of files names to keep in disk. Then, I search in my folder all files but I need check every files do not match with any element in my array. By example:
I think that both foreach is unnecessary, any better solution without use 2 for's?
foreach(string sFile in System.IO.Directory.GetFiles("C:\\*.bmp"))
bool flag = false;
foreach (string s in filesToUse)
flag = true;
if(flag) System.IO.File.Delete(sFile); //anyone of these are in filesToUse
Thanks in advance
this is not a dotnet solution, but deleting files is recommended with forfiles.exe utility.
here is information about forfiles.exe --> http://www.google.com/#sclient=psy&h...50e40e87b009cf