tags:

views:

61

answers:

5

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

+1  A: 

var file = new System.IO.File(path); file.Delete();

open-collar
Sorry, FileInfo.
open-collar
+1  A: 

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

Musa Hafalır
A: 

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

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

i.Delete();

Remeber to add:

using System.IO;
David Conde
-1 : not advisable when there is a trivial one-liner
Steve Townsend
This is the accepted answer? Really?
Steve Townsend
+2  A: 

You want File.Delete.

File.Delete(@"C:\Documents and Settings\Vijay.EKO-03\Desktop\blockseek3-9-2010\Block3.xml");
Joe White
This works fine thanks for your suggestion.
mahesh
+1  A: 

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");
Brendan Enrick