mahesh
mahesh

Reputation: 3207

how to delete a file?

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

Upvotes: 7

Views: 994

Answers (5)

open-collar
open-collar

Reputation: 1424

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

Upvotes: 2

Brendan Enrick
Brendan Enrick

Reputation: 4297

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

Upvotes: 1

Joe White
Joe White

Reputation: 97656

You want File.Delete.

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

Upvotes: 7

David Conde
David Conde

Reputation: 4637

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;

Upvotes: 0

Musa Hafalir
Musa Hafalir

Reputation: 1770

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

Upvotes: 2

Related Questions