How to delete a file?

How to delete a file, given the full path to the file?

+5
source share
5 answers

You want File.Delete .

File.Delete(@"C:\Documents and Settings\Vijay.EKO-03\Desktop\blockseek3-9-2010\Block3.xml");
+6
source
var file = new System.IO.File(path);
file.Delete();
+2
source

File.Delete(string path) the method will work, I think.

+2
source

Basically, you can just call the static delete method on the file class.

System.IO.File.Delete(@"C:\Documents and Settings\Vijay.EKO-03\Desktop\blockseek3-9-2010\Block3.xml");
+1
source

Have you tried this ??? I think this will solve your problems:

FileInfo i = new FileInfo("PATH TO YOUR FILE");

i.Delete();

Note:

using System.IO;
0
source

All Articles