title: zip and unzip string with Deflate
body: <p>I need to zip and unzip string</p>
  
  <p>Here is code: </p>
  
  <pre><code>public static byte[] ZipStr(String str)
  {
      using (MemoryStream output = new MemoryStream())
      using (DeflateStream gzip = new DeflateStream(output, CompressionMode.Compress))
      using (StreamWriter writer = new StreamWriter(gzip))
         {
                  writer.Write(str);
                  return output.ToArray();
         }
  }
  </code></pre>
  
  <p>and</p>
  
  <pre><code>public static string UnZipStr(byte[] input)
  {
      using (MemoryStream inputStream = new MemoryStream(input))
      using (DeflateStream gzip = new DeflateStream(inputStream, CompressionMode.Decompress))
      using (StreamReader reader = new StreamReader(gzip))
         {
          reader.ReadToEnd();
          return System.Text.Encoding.UTF8.GetString(inputStream.ToArray());
         }
  }
  </code></pre>
  
  <p>It seems that there is error in UnZipStr method. Can somebody help me? </p>