directory delete in use file c# code example
Example 1: how to delete all files in a directory c#
System.IO.DirectoryInfo di = new DirectoryInfo("YourPath");
foreach (FileInfo file in di.GetFiles())
{
file.Delete();
}
foreach (DirectoryInfo dir in di.GetDirectories())
{
dir.Delete(true);
}
Example 2: c# how to delete a file
File.Delete(@"C:\Temp\Data\Authors.txt");
Example 3: delete all dir content c#
new System.IO.DirectoryInfo(@"C:\Temp").Delete(true);
System.IO.Directory.Delete(@"C:\Temp", true);