title: Write to a stream as if it were a file, but really write to an object
body: <p>I am trying write a stream to the ram instead of a file. I tried doing this:</p>
  
  <pre><code>Stream stream = new MemoryStream();
  BinaryFormatter bFormatter = new BinaryFormatter();
  bFormatter.Serialize(stream, objectToSerialize);
  stream.Close();
  return stream;
  </code></pre>
  
  <p>But when I look at the stream after I have supposedly written to it it is saying "Length = 'stream.Length' threw an exception of type 'System.ObjectDisposedException'"</p>