Method 1
using System.IO; string[] filePaths = Directory.GetFiles(@"c:\Directory\"); foreach (string filePath in filePaths) File.Delete(filePath)
Method 2
To Delete all files using one code line, you can use Array.ForEach with combination of anonymous method.
Array.ForEach(Directory.GetFiles(@"c:\MyDirectory\"),delegate(string path) { File.Delete(path); });
No comments:
Post a Comment