using System.Web;
using System.IO;
/// <summary>
/// 根据路径删除文件
/// </summary>
/// <param name="path"></param>
public string DeleteFile(string path)
{
string retString;
try
{
string paths = System.Web.HttpContext.Current.Server.MapPath(path);
bool sta = File.Exists(paths);
if (sta)
{
File.Delete(paths);
retString = "{\"Code\":\"1\"}";
}
else
{
retString = "{\"Code\":\"-1\",\"Msg\":\"失败\"}";
}
}
catch (Exception ex)
{
retString = "{\"Code\":\"-1\",\"Msg\":\"失败:" + ex.Message + "\"}";
}
return retString;
}
根据路径删除文件、由相对路径转为绝对路径后进行删除
最新推荐文章于 2022-07-27 11:28:35 发布