title: What are the Equivalent methods to CopyTo() and WriteTo() in .Net Framework 3.5 and below?
body: <p>I need to use .NetFramework3.5 for my application, but <code>CopyTo()</code> and <code>WriteTo()</code> methods are not available in 3.5.  what are the equivalent methods in 3.5?</p>
  
  <p>when I run the code with 3.5 it is throwing the following error:</p>
  
  <blockquote>
    <p>'System.IO.Stream' does not contain a definition for 'WriteTo' and no extension method 'WriteTo' accepting a first argument of type 'System.IO.Stream' could be found</p>
  </blockquote>
  
  <p>Here is the code:</p>
  
  <pre><code>int fileId = 1;
  foreach (string uri in uriList)
  {
  
      request = (HttpWebRequest)WebRequest.Create (baseURL + uri);
      request.Headers.Add ("X", authenticateStr);
      request.Accept = "application/pdf";
      request.Method = "GET";
  
      webResponse = (HttpWebResponse)request.GetResponse();
      using (MemoryStream ms = new MemoryStream())
      using (FileStream outfile = new FileStream("document_", FileMode.Create)) {
          webResponse.GetResponseStream().WriteTo(ms);
          if (ms.Length &gt; int.MaxValue) {
              throw new NotSupportedException("Cannot write a file larger than 2GB.");
          }
          outfile.Write(ms.GetBuffer(), 0, (int)ms.Length);
      }
  }
  Console.WriteLine("Done!");
  </code></pre>