示例#1
0
 /// <summary>
 ///   Uncompress a GZip'ed byte array into a single string.
 /// </summary>
 ///
 /// <seealso cref="GZipStream.CompressString(String)"/>
 /// <seealso cref="GZipStream.UncompressBuffer(byte[])"/>
 ///
 /// <param name="compressed">
 ///   A buffer containing GZIP-compressed data.
 /// </param>
 ///
 /// <returns>The uncompressed string</returns>
 public static String UncompressString(byte[] compressed)
 {
     using (var input = new MemoryStream(compressed))
     {
         Stream decompressor = new GZipStream(input, CompressionMode.Decompress);
         return(ZlibBaseStream.UncompressString(compressed, decompressor));
     }
 }
示例#2
0
        /// <summary>
        ///   Uncompress a DEFLATE'd byte array into a single string.
        /// </summary>
        ///
        /// <seealso cref="DeflateStream.CompressString(String)">DeflateStream.CompressString(String)</seealso>
        /// <seealso cref="DeflateStream.UncompressBuffer(byte[])">DeflateStream.UncompressBuffer(byte[])</seealso>
        /// <seealso cref="GZipStream.UncompressString(byte[])">GZipStream.UncompressString(byte[])</seealso>
        /// <seealso cref="ZlibStream.UncompressString(byte[])">ZlibStream.UncompressString(byte[])</seealso>
        ///
        /// <param name="compressed">
        ///   A buffer containing DEFLATE-compressed data.
        /// </param>
        ///
        /// <returns>The uncompressed string</returns>
        public static String UncompressString(byte[] compressed)
        {
            using (var input = new System.IO.MemoryStream(compressed))
            {
                System.IO.Stream decompressor =
                    new DeflateStream(input, CompressionMode.Decompress);

                return(ZlibBaseStream.UncompressString(compressed, decompressor));
            }
        }