我的 .cs 代码
int ID = 24;
DAL objdal = new DAL(); //class
DataTable dt = new DataTable();
dt = objdal.select_delete_image(ID); //method to select and delete
string imagedel = "";
if (dt.Rows.Count > 0)
{
//image delete
imagedel = dt.Rows[0]["image_url"].ToString();
File.Delete((Server.MapPath("~/Admin/images/projects/small/" + imagedel.ToString()))); // process to delete
File.Delete((Server.MapPath("~/Admin/images/projects/large/" + imagedel.ToString()))); // process to delete
}
string strScript = "<script language='JavaScript'>alert('Image Deleted Successfully')</script>";
Page.RegisterStartupScript("PopUp", strScript);
这里数据库条目被删除,但文件夹中的图像没有被删除。
这一切在 localhost 中运行良好,但在服务器端出现问题