发布新日志

  • 在内存中直接解压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();

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

     

我的栏目

我的存档

数据统计

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

RSS订阅

Open Toolbar