我在 asp.net 中使用 c# 编写代码来删除我计算机中的文件,但它没有删除,请帮助我,谢谢。这是我的代码,我写在按钮点击事件中
string path = "E:\\sasi\\delt.doc";
FileInfo myfileinf = new FileInfo(path);
myfileinf.Delete();
最佳答案
public void DeleteFileFromFolder(string StrFilename)
{
string strPhysicalFolder = Server.MapPath("..\\");
string strFileFullPath = strPhysicalFolder + StrFilename;
if (IO.File.Exists(strFileFullPath)) {
IO.File.Delete(strFileFullPath);
}
}
关于c# - 如何使用 asp.net 删除文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1762157/