@{ bool deleteSuccess = false; var photoName = ""; if (IsPost) { photoName = Request["photoFileName"] + ".jpg"; var fullPath = Server.MapPath("~/images/" + photoName); if (File.Exists(fullPath)) { File.Delete(fullPath); deleteSuccess = true; } } } Delete a Photo

Delete a Photo from the Site

File name of image to delete (without .jpg extension):

@if(deleteSuccess) {

@photoName deleted!

}