Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Delete a file using asp.net?

Tags:

c#

asp.net

i write the code in asp.net using c# to delete the file in my computer, but it is not deleting please help me thank u. this is my code, i write in button click event

        string path = "E:\\sasi\\delt.doc";
        FileInfo myfileinf = new FileInfo(path);
        myfileinf.Delete();
like image 762
Surya sasidhar Avatar asked Jan 22 '23 23:01

Surya sasidhar


1 Answers

public void DeleteFileFromFolder(string StrFilename)
{

    string strPhysicalFolder = Server.MapPath("..\\");

    string strFileFullPath = strPhysicalFolder + StrFilename;

    if (IO.File.Exists(strFileFullPath)) {
        IO.File.Delete(strFileFullPath);
    }

}
like image 170
BJ Patel Avatar answered Jan 30 '23 01:01

BJ Patel