c# delete file if exists code example
Example 1: c# how to delete a file
File.Delete(@"C:\Temp\Data\Authors.txt");
Example 2: c# delete file if exists
if(File.Exists(@"C:\test.txt"))
{
File.Delete(@"C:\test.txt");
}
File.Delete(@"C:\Temp\Data\Authors.txt");
if(File.Exists(@"C:\test.txt"))
{
File.Delete(@"C:\test.txt");
}