To delete a file in Windows using a WPF, Form or Console App you could use the following code:
Add System.OI using then use File.Delete method
1 2 3 | using System.IO; |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | class Program { static void Main(string[] args) { //delete file string destinationFile = @"D:\sample\file.txt"; try { File.Delete(destinationFile); } catch (IOException ex) { Console.WriteLine(ex.Message); } } } |