title: Response.BinaryWrite() - Getting Junk at the beginning of file
body: <p>I'm trying to write a string to a file that a user can download from my site.</p>
  
  <pre><code>var tcxString = "Some code to get my string";
  
  byte[] bytes;
  MemoryStream cvsStream = new MemoryStream();
  BinaryFormatter bf = new BinaryFormatter();
  bf.Serialize(cvsStream, tcxString);
  
  cvsStream.Seek(0, SeekOrigin.Begin);
  bytes = cvsStream.ToArray();
  
  Response.Clear();
  Response.AppendHeader("content-length", cvsStream.Length.ToString());
  Response.ContentType = "application/octet-stream";
  Response.AppendHeader("content-disposition", "attachment; filename=MyFileName.txt");
  Response.BinaryWrite(bytes);
  </code></pre>
  
  <p>The output becomes:</p>
  
  <pre><code>    ÿÿÿÿ          Some code to get my string
  </code></pre>
  
  <p>I'm guessing it has to do with my Seek location but I don't know what the correct Seek should be.  I see junk at the end of my file sometimes too.  How can I get rid of the junk at the beginning and end of my file?</p>