In this article csharpcanban.com will guide you How to Delete a File in C#, with examples and Demo code, you can download for use.
The Delete method deletes the specified file permanently. The following code snippet deletes a file:
string fileName = @"C:FileToDelete.txt";
FileInfo filetodelete = new FileInfo(fileName);
try
{
filetodelete.Delete();
}
catch (IOException ex)
{
Console.WriteLine(ex.Message);
}