public ActionResult Delete(int id) { CourseDao dao = new CourseDao(); course exists_cou = dao.GetById(id); var image_old = Path.Combine(Server.MapPath("~/Areas/Admins/Content/Photo/course/"), System.IO.Path.GetFileName(exists_cou.co_image)); if (System.IO.File.Exists(image_old)) { System.IO.File.Delete(image_old); } dao.Delete(id); return(RedirectToAction("Index")); }