I cant delete an image after uploading in c# mvc.it shows an exception in File.delete(path)

Exception:
The process cannot access the file 'D:\ebook\alignment11429852064.png' because it is being used by another process

fileupload process:

```
     public void UploadImage(HttpPostedFileBase file, FileImage upload)
     {
         try
         {
             string fileName = Path.GetFileNameWithoutExtension(file.FileName);
             string fileExtension = Path.GetExtension(file.FileName);
             string hashFile = fileName + DateTime.Now.GetHashCode();
             string path = Path.Combine(HttpContext.Current.Server.MapPath("D\ebook" + hashFile + fileExtension));
             upload.ImageFile = "D\ebook" + hashFile + fileExtension;
             file.SaveAs(path);
         }
         catch(exception e)
         {
         }
     }

```

FileImage is a model

here I have written for deleting file(image) function

```
public ProfileImage DiscardImage(FileImage image)
{
     try
     {
         if(File.Exists(HttpContext.Current.Server.MapPath(image.ImageFile)))
         {
             File.Delete(HttpContext.Current.Server.MapPath(image.ImageFile));
         }
     }
     catch(exception e)
     {
     }    
 }

```