Delete a large number (>100K) of files with c# whilst maintaining performance in a web application?
I am trying to remove a large number of files from a location (by large I mean over 100000), whereby the action is initated from a web page. Obviously I could just use string[] files = System.IO.Directory.GetFiles("path with files to delete"); foreach (var file in files) { IO.File.Delete(file); } Directory.GetFiles http://msdn.microsoft.com/en-us/library/wz42302f.aspx This method has already been posted a few times: How to delete all files and folders in a directory? and Delete files from directory if filename contains a certain word But the problem with this method is that if you have say a