title: download a file from server and then delete on server
body: <p>ok i am downloading a file from a server and i plan to delete the file that i have downloaded on the server after it gets downloaded on the client side..</p>
  
  <p>My download code is working fine but i dont know when to put the command to delete the file.</p>
  
  <pre><code>string filepath = restoredFilename.ToString();
  
              // Create New instance of FileInfo class to get the properties of the file being downloaded
              FileInfo myfile = new FileInfo(filepath);
  
              // Checking if file exists
              if (myfile.Exists)
              {
  
                  // Clear the content of the response
                  Response.ClearContent();
  
                  // Add the file name and attachment, which will force the open/cancel/save dialog box to show, to the header
                  Response.AddHeader("Content-Disposition", "attachment; filename=" + myfile.Name);
  
                  //Response.AddHeader("Content-Disposition", "inline; filename=" + myfile.Name);
                  // Add the file size into the response header
                  Response.AddHeader("Content-Length", myfile.Length.ToString());
  
                  // Set the ContentType
                  Response.ContentType = ReturnExtension(myfile.Extension.ToLower());
  
                  //// Write the file into the response (TransmitFile is for ASP.NET 2.0. In ASP.NET 1.1 you have to use WriteFile instead)
                  Response.TransmitFile(myfile.FullName);
  
                  // End the response
                  Response.End();
  
              }
  </code></pre>
  
  <p>Now i know the response.End() will stop every thing and return the value, so is there another way too do so..</p>
  
  <p>I need to call a function </p>
  
  <blockquote>
    <p>DeleteRestoredFileForGUI(restoredFilename);</p>
  </blockquote>
  
  <p>to delete the file but dont know where to put it.. i tried putting before and after Response.End() but it does not work..</p>
  
  <p>any help is appreciated... thanks</p>