title: ASP.NET C# FileUpload.SaveAs(filename) for large files
body: <p>I am trying to upload files to a server using the FileUpload control in ASP.Net. I want to able to upload files that exceed 1GB, and probably would never be bigger than 2GB. Currently i have this upload code:</p>
  
  <pre><code>string filename = FileUpload1.PostedFile.FileName;
  filename = filename.Remove(filename.Count() - 4) + "-" + DateTime.Now.ToShortDateString() + ".zip";
  filename = filename.Replace(" ", "-");
  filename = filename.Replace("/", "-");
  
  //attempt to save the file
  FileUpload1.SaveAs("C:\\Uploads\\" + filename);
  </code></pre>
  
  <p>The error i get with this is that the server times out after a long time of trying to upload a file. I have read around extensively, and found many suggestions to do with my web.config which now looks like this:</p>
  
  <pre><code>&lt;system.web&gt;
    &lt;compilation debug="true" targetFramework="4.5" /&gt;
    &lt;httpRuntime targetFramework="4.5" maxRequestLength="999999999" executionTimeout="100000000" /&gt;
    &lt;customErrors mode="Off"/&gt;
  &lt;/system.web&gt;
  &lt;system.webServer&gt;
    &lt;security&gt;
      &lt;requestFiltering&gt;
        &lt;requestLimits maxAllowedContentLength="4000000000"/&gt;
      &lt;/requestFiltering&gt;
    &lt;/security&gt;
  &lt;/system.webServer&gt;
  </code></pre>
  
  <p>I do not want to use a tool already written eg. NeatUpload, as i would really like to have this current code working. If anyone has any suggestions, or would like some more details please let me know, thanks.</p>