public string delimge(string AttachmentID, string fileUrl) { string connstrs = ""; try { connstrs = this.Request.Headers["ProjectType"].ToString(); } catch (Exception e) { connstrs = "SqlConnectionStr"; } try { var Purl = fileUrl.Replace("http://192.***.*.***/Api", ""); //删除根目录图片(单张) string file = System.Web.HttpContext.Current.Server.MapPath("../" + Purl); file = file.Replace(",", ""); if (System.IO.File.Exists(file)) { System.IO.File.Delete(file); ; } string sql = ""; sql += "delete Attachment where AttachmentID=" + AttachmentID; var num = SqlHelper.ExecuteNonQuery(sql.ToString(), connstrs); return format.ResultJsonData("SUCCESS", "删除信息成功!", num); } catch (Exception ex) { return format.ResultJsonData("FAILED", "删除失败!", 0); } }
标签:string,删除,connstrs,System,文件夹,file,根目录 From: https://www.cnblogs.com/fuyao/p/17702619.html