string[] filePaths = Directory.GetFiles(@"c:\MyDir\");
foreach (string filePath in filePaths)
File.Delete(filePath);
Or in a single line:
Array.ForEach(Directory.GetFiles(@"c:\MyDir\"), File.Delete);
string[] filePaths = Directory.GetFiles(@"c:\MyDir\");
foreach (string filePath in filePaths)
File.Delete(filePath);
Or in a single line:
Array.ForEach(Directory.GetFiles(@"c:\MyDir\"), File.Delete);