title: Compression and decompression problem with zlib.Net
body: <p>I am using <a href="http://www.componentace.com/zlib_.NET.htm" rel="nofollow">ZLIB.Net</a> and I just don't understand what should I do to compress a stream which is not <code>FileStream</code>, but <code>MemoryStream</code>. By doing:</p>
  
  <pre><code>byte[] buffer = ASCIIEncoding.ASCII.GetBytes("Hello World");
  
  MemoryStream outStream = new MemoryStream();
  zlib.ZOutputStream outZStream = new zlib.ZOutputStream(
      outStream,
      zlib.zlibConst.Z_BEST_COMPRESSION);
  
  outZStream.Write(buffer, 0, buffer.Length);
  outZStream.finish();
  
  buffer = outStream.GetBuffer();
  Debug.WriteLine(DateTime.Now.ToString() + ":" + buffer.Length);
  
  MemoryStream inStream = new MemoryStream(buffer);
  MemoryStream mo = new MemoryStream();
  zlib.ZInputStream inZStream = new zlib.ZInputStream(
      inStream,
      zlib.zlibConst.Z_BEST_COMPRESSION);
  
  int n = 0;
  while ((n = inZStream.Read(buffer, 0, buffer.Length)) &gt; 0)
  {
      mo.Write(buffer, 0, n);
  }
  
  string STR = ASCIIEncoding.ASCII.GetString(mo.GetBuffer());
  </code></pre>
  
  <p>I can't get the string <code>"Hello World"</code> back.</p>