GZip解压.NET代码

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;
        }
posted @ 2012-04-20 21:42  appleii  阅读(348)  评论(0)    收藏  举报