C#删除文件
/// <summary> /// 删除文件 /// </summary> /// <param name="fileUrl">路径</param> public string DeleteImgFile(string id, string url) { var obj = new object { }; try { string file = System.Web.HttpContext.Current.Server.MapPath(url); if (System.IO.File.Exists(file)) { System.IO.File.Delete(file); HealthCls cls = new HealthCls(); return cls.DeleteImgFile(id, url); } else { obj = new { errCode = 0, errMessage = "成功!" }; return JsonConvert.SerializeObject(obj); } } catch (Exception ex) { obj = new { errCode = 1, errMessage = ex.Message }; return JsonConvert.SerializeObject(obj); } }