title: Why downloaded file is bigger than input stream?
body: <p>I'm writing a C# method to get a MemoryStream and download it as file in browser.
  I load a .xlsx file using FileStream and copy it to MemoryStream</p>
  
  <pre><code>using (FileStream fs = new FileStream(Filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
  {
      docStream = new MemoryStream();
      fs.CopyTo(docStream);
  }
  </code></pre>
  
  <p>Then I pass the docStream to OpenXML class</p>
  
  <pre><code>using (SpreadsheetDocument spreadSheet = SpreadsheetDocument.Open(docStream, true))
  </code></pre>
  
  <p>and update the content using OpenXML classes and methods.
  Finally I pass the docStream to DownloadStream method but, the downloaded file is larger than size of the stream.</p>
  
  <pre><code>public class Utility
  {
      public static void DownloadStream(MemoryStream inputStream, string filename)
      {
          byte[] bytes = inputStream.ToArray();
  
          HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=" + filename);
          HttpContext.Current.Response.AddHeader("Content-Length", bytes.Length.ToString());
          HttpContext.Current.Response.ContentType = "application/octet-stream";
          HttpContext.Current.Response.BinaryWrite(bytes);
      }
  }
  </code></pre>
  
  <p>I put a break-point and verified the <code>inputStream.Lentgh</code> is <code>17112</code> bytes.
  I also confirmed that <code>bytes.Length</code> is <code>17112</code>. </p>
  
  <p>When I check the download file (which is an .xslx), it's size is <code>25983</code> bytes.</p>
  
  <p>Also when I open the file, I get a warning that file may corrupt but Excel is is able to repair it.</p>