title: How do I download a large file (via HTTP) in .NET?
body: <p>I need to download a <em>large</em> file (2&nbsp;GB) over HTTP in a C# console application. Problem is, after about 1.2&nbsp;GB, the application runs out of memory.</p>
  
  <p>Here's the code I'm using:</p>
  
  <pre><code>WebClient request = new WebClient();
  request.Credentials = new NetworkCredential(username, password);
  byte[] fileData = request.DownloadData(baseURL + fName);
  </code></pre>
  
  <p>As you can see... I'm reading the file directly into memory. I'm pretty sure I could solve this if I were to read the data back from HTTP in chunks and write it to a file on disk.</p>
  
  <p>How could I do this?</p>