title: C# MemoryStream is larger than FileStream
body: <p>I've a method to compress a byte-array. I used a memorystream and a filestream for testing. the result from the memorystream is larger, even if its the same method, can anyone explain why?</p>
  
  <pre><code>public byte[] DeflateCompress(byte[] data2Compress)
  {
      using (FileStream _fileToCompress = File.Create("_deflatecompressed.bin"))
      {
          using (DeflateStream _compressionStream = new DeflateStream(_fileToCompress, CompressionMode.Compress))
          {
              _compressionStream.Write(data2Compress, 0, data2Compress.Length);
              _compressionStream.Close();
          }
      }
  
      return File.ReadAllBytes("_deflatecompressed.bin");
  }
  
  public byte[] DeflateCompress(byte[] data2Compress)
  {
      using (MemoryStream _memStreamCompress = new MemoryStream())
      {
          using (DeflateStream _defalteStreamCompress = new DeflateStream(_memStreamCompress, CompressionMode.Compress))
          {
              _defalteStreamCompress.Write(data2Compress, 0, data2Compress.Length);
              _defalteStreamCompress.Close();
          }
  
          return _memStreamCompress.GetBuffer();
      }
  }
  </code></pre>
  
  <p>If I write the output byte-array to a file, then the one created with memorystream is larger.</p>