title: c# ZLib.Net decompression
body: <p>I'm trying to decompress a byte array using the <code>ZLib.Net</code> library. Unfortunately my function is always returning two bytes only. The compressed array has 1240 bytes. No one of <code>zlibConst</code> values does return more than two bytes.</p>
  
  <p>Maybe something is wrong with <code>ZLib.Net</code>? (the DLL is taken from here: <a href="http://zlibnet.codeplex.com/" rel="nofollow">http://zlibnet.codeplex.com/</a>)</p>
  
  <pre><code>byte[] Decompress(byte [] compressed)
  {
      byte[] rez = new byte[compressed.Length];
  
      MemoryStream oInStream = new MemoryStream(compressed);
      ZInputStream oZInstream = new ZInputStream(oInStream, zlibConst.Z_BEST_COMPRESSION);
      MemoryStream oOutStream = new MemoryStream();
  
      byte[] buffer = new byte[2000];
      int len;
      while ((len = oZInstream.read(buffer, 0, 2000)) &gt; 0)
      {
          oOutStream.Write(buffer, 0, len);
      }
      oOutStream.Flush();
      byte[] arrUncompressed = oOutStream.ToArray();
      oZInstream.Close();
      oOutStream.Close();
  
      return arrUncompressed;
  }
  </code></pre>