Wednesday, July 29, 2009

how to delete file from folder in C#,asp.net ?

string FileName =test.doc";
string FilePath = "c:\\" + FileName;
FileInfo TheFile = new FileInfo(FilePath);
if (TheFile.Exists)
{
TheFile.Delete();
//File.Delete(FilePath);
}
else
{
throw new FileNotFoundException();
}

No comments:

Post a Comment