物理删除文件 业务层
public void Delete(string projectID, string strItemID, string strType)
{
string AppPath = "";
HttpContext HttpCurrent = HttpContext.Current;
if (HttpCurrent != null)
{
AppPath = HttpCurrent.Server.MapPath("~");
}
else
{
AppPath = AppDomain.CurrentDomain.BaseDirectory;
if (Regex.Match(AppPath, @"\\$", RegexOptions.Compiled).Success)
AppPath = AppPath.Substring(0, AppPath.Length - 1);
}
//AppPath = AppPath + "\\ResourceFiles\\";
string strPath = "";
DataSet ds=new DataSet();
ds=GetDataByItemID(projectID,strItemID,strType);
if(ds!=null&&ds.Tables.Count>0 && ds.Tables[0].Rows.Count>0)
{
for(int i=0;i<ds.Tables[0].Rows.Count;i++)
{
strPath = ds.Tables[0].Rows[i]["Path"].ToString();
strPath = strPath.Substring(2,strPath.Length-2);
strPath = AppPath + strPath;
File.Delete(strPath);
}
}
string strSQL;
strSQL = "delete from Resource where ProjectInfoID=" + projectID + " and comment='" + strType + "' and ProcessSetID ='" + strItemID + "' ";
sa.ExecuteSQL(strSQL);
}
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步