7

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

3
  • 1
    What error are you receiving? Commented Sep 3, 2010 at 12:24
  • No i am not receiving error , i want to delete that particular file Block3.xml stored in that particular directory i am not able to judge the syntax for delete Commented Sep 3, 2010 at 12:29
  • 3
    did you look it up? System.IO.File.Delete. Commented Sep 3, 2010 at 12:35

5 Answers 5

7

You want File.Delete.

File.Delete(@"C:\Documents and Settings\Vijay.EKO-03\Desktop\blockseek3-9-2010\Block3.xml"); 
Sign up to request clarification or add additional context in comments.

Comments

2

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

Comments

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

Comments

1

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

Comments

0

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; 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.