In this tutorial we will see how to delete a File in C#. We will be using the File.Delete() method for file deletion.
Source Code:
1 2 3 | using System.IO; |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | private static void Main() { string destinationFile = @"D:\cce.txt"; try { File.Delete(destinationFile); } catch (IOException ioex) { Console.WriteLine(ioex.Message); } Console.ReadKey(); } |