title: How I Delete File after uploading in ASP.net FileUpload Control
body: <pre><code>string savePath = Server.MapPath(&quot;\\Upload_File\\&quot;);
  // Get the name of the file to upload.
  string fileName = email_attach.FileName;
  string pathToCheck = savePath + fileName;
  
  
  email_attach.SaveAs(pathToCheck);
  
  string file = pathToCheck;
  Attachment data = new Attachment(file);
  mail.Attachments.Add(data);
  
  SmtpServer.Port = 587;
  SmtpServer.Credentials = new System.Net.NetworkCredential(&quot;username&quot;, &quot;password&quot;);
  SmtpServer.EnableSsl = true;
  SmtpServer.Send(mail);
  email_attach.Dispose();
  FileInfo file_Delete = new FileInfo(pathToCheck);
  if (file_Delete.Exists)
  {
      file_Delete.GetAccessControl();
      file_Delete.Delete();
  }
  </code></pre>
  <p>when i did this it throws exception like</p>
  <blockquote>
  <p>An exception of type 'System.IO.IOException' occurred in mscorlib.dll but was not handled in user code</p>
  <p>Additional information: The process cannot access the file 'C:\Users\User\Documents\Visual Studio 2013\WebSites\Email_Sent_Web\Upload_File\DMP.edx' because it is being used by another process.</p>
  </blockquote>
  <p>how i solve plz help ,thanks in Advance</p>