Answers for "how to delete all files in a directory c#"

C#
3

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); 
}
Posted by: Guest on September-22-2020
12

c# how to delete a file

File.Delete(@"C:\Temp\Data\Authors.txt");
Posted by: Guest on March-10-2020
1

C# delete folder with all contents

System.IO.Directory.Delete("C:\TempTest", True)
Posted by: Guest on December-14-2020

Code answers related to "how to delete all files in a directory c#"

C# Answers by Framework

Browse Popular Code Answers by Language