title: Copy data from MemoryStream directly to BinaryWriter.BaseStream?
body: <p>I have a bunch of data in a <code>MemoryStream</code> and I want to write all of it to a <code>BinaryWriter</code>.</p>
  
  <p>Lucky for me all streams now have a <a href="http://msdn.microsoft.com/en-us/library/dd782932.aspx" rel="nofollow"><code>Stream.CopyTo(Stream)</code> method</a>, and I can get the target stream from the <a href="http://msdn.microsoft.com/en-us/library/system.io.binarywriter.basestream.aspx" rel="nofollow"><code>BinaryWriter.BaseStream</code> property</a>.</p>
  
  <pre><code>public void WriteTo(BinaryWriter writer)
  {
      this.memoryStream.CopyTo(writer.BaseStream);
  }
  </code></pre>
  
  <p>Can I safely bypass the writer like this and copy it directly to the base stream, or will this mess up the writer's buffer, position, or something else? Or, how would you propose copying a <code>Stream</code> to a <code>BinaryWriter</code>?</p>