GZip解压.NET代码

来源:岁月联盟 编辑:exp 时间:2012-04-21

public static byte[] GZipDecompress(Byte[] bytes)
        {
            BinaryReader br = null;
            System.IO.Compression.GZipStream dcmp = null;

            try
            {
                using (MemoryStream ms = new MemoryStream(bytes))
                {
                    dcmp = new System.IO.Compression.GZipStream(ms, System.IO.Compression.CompressionMode.Decompress);
                    br = new BinaryReader(dcmp);
                    return br.ReadBytes((int)dcmp.Length);
                }
            }
            catch (System.Exception e)
            {

            }
            finally
            {
                br.Close();
                dcmp.Close();
            }
           
            return bytes;
        }
 

 

摘自 appleII的博客