title: What is the simplest way to decompress a ZIP buffer in C#?
body: <p>When I use <strong>zlib</strong> in C/C++, I have a simple method <code>uncompress</code> which only requires two buffers and no more else. Its definition is like this:</p>
  
  <blockquote>
  <pre><code>int uncompress (Bytef *dest, uLongf *destLen, const Bytef *source,
  uLong sourceLen); 
  /*
  Decompresses the source buffer into the destination buffer.  sourceLen is    the byte length of the source buffer.  Upon entry,
  destLen is the total size    of the destination buffer, which must be
  large enough to hold the entire    uncompressed data.  (The size of
  the uncompressed data must have been saved    previously by the
  compressor and transmitted to the decompressor by some    mechanism
  outside the scope of this compression library.) Upon exit, destLen   
  is the actual size of the uncompressed data.
  
  uncompress returns Z_OK if success, Z_MEM_ERROR if there was not    enough memory, Z_BUF_ERROR if there was not enough room in the output 
  buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete.
  In    the case where there is not enough room, uncompress() will fill
  the output    buffer with the uncompressed data up to that point.
  */
  </code></pre>
  </blockquote>
  
  <p>I want to know if C# has a similar way. I checked <strong><a href="https://github.com/icsharpcode/SharpZipLib/wiki/FAQ" rel="nofollow noreferrer">SharpZipLib FAQ</a></strong> as follows but did not quite understand:</p>
  
  <blockquote>
    <p><strong>How do I compress/decompress files in memory?</strong></p>
    
    <p>Use a memory stream when creating the Zip stream!</p>
  
  <pre><code>MemoryStream outputMemStream = new MemoryStream();
  using (ZipOutputStream zipOutput = new ZipOutputStream(outputMemStream)) {   
  // Use zipOutput stream as normal    
  ...  
  </code></pre>
    
    <p>You can get the resulting data with memory stream methods ToArray or GetBuffer.</p>
    
    <p>ToArray is the cleaner and easiest to use correctly with the penalty
    of duplicating allocated memory. GetBuffer returns a raw buffer raw
    and so you need to account for the true length yourself.</p>
    
    <p>See the framework class library help for more information.</p>
  </blockquote>
  
  <p>I can't figure out if this block of code is for compression or decompression, if <code>outputMemStream</code> meas a compressed stream or an uncompressed stream. I really hope there is a easy-to-understand-way like in zlib. Thanks you very much if you can help me.</p>