title: C# Webclient Stream download file from FTP to local storage
body: <p>I've been downloading files from an FTP server via the <code>WebClient</code> object that the <code>.NET</code> namespace provides and then write the bytes to a actual file via a <code>BinaryWriter</code>.  All is good.  However, now, the files have dramatically increased in size and I'm worried about memory constraints so I'd like to create a download stream, create an file stream, and line by line read from the download and write to the file.</p>
  
  <p>I'm nervous since I couldn't find a nice example of this. Here's my end result:</p>
  
  <pre><code>var request = new WebClient();
  
  // Omitted code to add credentials, etc..
  
  var downloadStream = new StreamReader(request.OpenRead(ftpFilePathUri.ToString()));
  using (var writeStream = File.Open(toLocation, FileMode.CreateNew))
  {
      using (var writer = new StreamWriter(writeStream))
      {
          while (!downloadStream.EndOfStream)
          {
              writer.Write(downloadStream.ReadLine());                  
          }
      }
  }
  </code></pre>
  
  <p>Am I going about this incorrect/better way/etc?</p>