Delete all files and directories except the ones in a list
I have two tasks in hand 1) Get 10 latest files from a folder lets say
C:\Temp and 2) Delete any other folders and files.
I got the first item working by using the below code, thanks for our
friends in stackoverflow.
var imgFiles = (from f in
directory.GetFiles(fileType,SearchOption.AllDirectories)
orderby f.LastWriteTime descending
select f).Take(numberOfFilesToFetch).ToArray();
I need some help with point 2. Some sample C# code will be really helpful.
Thank you.
No comments:
Post a Comment