public ActionResult DeleteSubmission(int id) { var listOwnFile = dataAccess.GetFilesBySubID(id); if (listOwnFile.Count() > 0) { var rootFolder = Server.MapPath("~/Uploads/FilesSubmitted/"); foreach (var item in listOwnFile) { if (System.IO.File.Exists(Path.Combine(rootFolder, item.File_Path))) { System.IO.File.Delete(Path.Combine(rootFolder, item.File_Path)); } } } var res = dataAccess.DeleteSubmission(id); return(Json(res, JsonRequestBehavior.AllowGet)); }