在内存中直接解压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:
心得