public ContentResult ToDel(int id) { BaseParameters oldpara = BaseParameters.GetEntityByID(id); if (BaseParameters.DeleteByID(id) > 0) { if (oldpara.valType == "image") { try { string oldImgUrl = oldpara.ParametersVal;//原来的图片 if (oldImgUrl.Contains("?")) { oldImgUrl = oldImgUrl.SubStringSafe(0, oldImgUrl.IndexOf("?")); } if (string.IsNullOrWhiteSpace(oldImgUrl) == false) { string delFile = Server.MapPath("~") + oldImgUrl; System.IO.File.Delete(delFile); } } catch (Exception ex) { } } return(Content("ok")); } return(Content("删除出错")); }