title: C# How to copy a stream into a streamwriter
body: <p>I want to copy the content of a <code>Stream</code> (containing an image) into the a <code>StreamWriter</code> (where I'm writing a webrequest), so far I'm unable to do this.</p>
  
  <p>I tried <code>imageStream.CopyTo(streamWriter);</code> but that didn't work because it can only copy it to another Stream and not a StreamWriter.</p>
  
  <p>I hope some can help me!</p>
  
  <p><strong>EDIT: CODE ADDED</strong></p>
  
  <pre><code>request.BeginGetRequestStream((requestResult =&gt;
  {
      Stream stream = request.EndGetRequestStream(requestResult);
      using (StreamWriter streamWriter = new StreamWriter(stream))
      {
          streamWriter.WriteLine(boundary);
          streamWriter.WriteLine("Content-Disposition: form-data; name=\"json\"");
          streamWriter.WriteLine("Content-Type: text/plain; charset=utf-8");
          streamWriter.WriteLine("Content-Transfer-Encoding: 8bit");
  
          streamWriter.WriteLine(json);
  
          streamWriter.WriteLine(boundary);
          streamWriter.WriteLine("Content-Disposition: form-data; name=\"image\"; filename=\"image.jpg\"");
          streamWriter.WriteLine("Content-Type: application/octet-stream");
          streamWriter.WriteLine("Content-Transfer-Encoding: binary");
          streamWriter.WriteLine("");
  
          streamWriter.Flush();
  
          image.CopyTo(streamWriter.BaseStream);
          // image.CopyTo(stream); // also not working
  
          streamWriter.WriteLine("");
          streamWriter.WriteLine(boundary);
  
          streamWriter.Close();
      }
  
      ExecuteRequest(this, request);
  
  }), request);
  </code></pre>