public void deleteSinglePhoto(int photoid, string folderLocation) { try { renoRatorDBEntities db = new renoRatorDBEntities(); Photo p = db.Photos.FirstOrDefault(ph => ph.photoID == photoid); string path = folderLocation + p.path.Substring(16); string thumbPath = folderLocation + p.thumbPath.Substring(16); // delete actual file from server System.IO.File.Delete(path); System.IO.File.Delete(thumbPath); db.DeleteObject(p); db.SaveChanges(); } catch { } }