在内存中直接解压zip格式数据

上一篇 / 下一篇  2007-11-08 23:15:24 / 个人分类:心得

  工作中,有时候需要直接截获网络数据进行解压,SharpZip中的ZipInputStream不适用此场合,于是使用InflaterInputStream代替:

                string strStream = string.Empty;
                MemoryStream sourceStream = new MemoryStream();
                sourceStream.Write(byte_zipCode, 0, byte_zipCode.Length);
                byte[] buffer = new byte[2048];
                sourceStream.Position = 0;              
                InflaterInputStream ZipCompession = new InflaterInputStream(sourceStream);               
                while(true)
                {
                    int iCount = ZipCompession.Read(buffer, 0, buffer.Length);
                    if (iCount == 0)
                    {
                        break;
                    }
                }
                strStream = Encoding.Default.GetString(buffer).Trim();

   写个小测试工具既解决了麻烦,又留下铁证找开发切磋^_^

 


相关阅读:

TAG: 心得

 

评分:0

我来说两句

我的栏目

日历

« 2024-05-09  
   1234
567891011
12131415161718
19202122232425
262728293031 

我的存档

数据统计

  • 访问量: 819
  • 日志数: 1
  • 建立时间: 2007-11-08
  • 更新时间: 2007-11-08

RSS订阅

Open Toolbar