For Deleting all the files first you need to get the list of file names from the specified directory (using static method Directory.GetFiles. Then delete all files from the list.
To Delete all files using one code line, you can use Array.ForEach with combination of anonymous method.
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); });