[英]how to get path of the file to be deleted from the server
i want to delete a file present in directory on the server. 我想删除服务器目录中存在的文件。 I have tried following code but code inside the file.exist never runs.
我尝试了以下代码,但是file.exist内部的代码从未运行。 It always skips it showing me that file does not exist.
它总是跳过它,向我显示该文件不存在。 But file is present.
但是文件存在。 can smone please help me.
可以纵容,请帮助我。 Thanx in advance
提前感谢
string filename = "Template\\copy.jpg";
if(System.IO.File.Exists(filename))
{
System.IO.File.Delete(filename);
}
尝试
string fileName = Server.MapPath(@"/Template/copy.jpg");
You can use Server.MapPath
to get the path. 您可以使用
Server.MapPath
来获取路径。 eg 例如
string filename = Server.MapPath("~/Template/copy.jpg");
System.IO.File.Delete(filename);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.