public JsonResult Delete_Attachment(long attachment_Id) { List <FriendlyMessageInfo> Friendly_Message = new List <FriendlyMessageInfo>(); AttachmentsInfo attachments = new AttachmentsInfo(); try { AjaxManager aMan = new AjaxManager(); attachments = aMan.Get_Attachment_By_Id(attachment_Id); var saveToFileLoc = string.Format("{0}\\{1}", Server.MapPath("/uploads/" + attachments.Ref_Type_Str + "/" + attachments.Ref_Id), attachments.Document_Name); if (saveToFileLoc != null || saveToFileLoc != string.Empty) { if ((System.IO.File.Exists(saveToFileLoc))) { System.IO.File.Delete(saveToFileLoc); } } aMan.Delete_Attachment_By_Id(attachment_Id); Friendly_Message.Add(MessageStore.Get("AJ002")); } catch (Exception ex) { Friendly_Message.Add(MessageStore.Get("SYS01")); Logger.Error("Ajax Controller - Delete_Attachment " + ex.ToString()); } return(Json(new { Friendly_Message }, JsonRequestBehavior.AllowGet)); }