C#,使用zlib解压缩流 [英] C#, Decompress a stream using zlib

查看:621
本文介绍了C#,使用zlib解压缩流的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试解压缩字节数组。

I am trying to decompress a byte array.

byte[] bloc = { 120, 156, 211, 97, 144, 76, 247, 142, 98, 228, 98, 0, 2, 70, 101, 6, 166, 8, 16, 131, 133, 131, 145, 129, 209, 134, 129, 133, 1, 44, 12, 4, 202, 118, 12, 0, 70, 22, 2, 148 };

您可以看到标头为120165(十六进制为78 9c),是zlib的默认压缩方式算法。
我使用zlib站点中的ComponentAce.Compression.ZipForge。
我找不到如何解压缩流(不是文件)的示例。

As you can see the header is 120 165 (78 9c in hex) witch is the zlib default Compression algorithme. I used the ComponentAce.Compression.ZipForge from the zlib site. I couldn't find samples on how to unzip streams(not files).

推荐答案

使用 SharpZipLib 。它包含zlib的完整接口,并且将解压缩zlib流以及其他压缩数据格式,例如gzip,zip,bzip2和原始deflate。

Use SharpZipLib. It includes a full interface to zlib, and will decompress zlib streams as well as other compressed data formats such as gzip, zip, bzip2, and raw deflate.

Microsoft提供的.NET组件存在问题(尤其是无法正确检测到无效输入),并且Microsoft已声明它们无法修复它

You should avoid the .NET components provided by Microsoft as they are buggy (in particular in not properly detecting invalid input) and Microsoft has stated that they will not fix it.

这篇关于C#,使用zlib解压缩流的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆