【C#笔记】BZip2OutputStream和GZipStream压缩问题

来源:互联网 发布:网络舆论的特点 编辑:程序博客网 时间:2024/05/16 14:47

在使用ICSharpCode.SharpZipLib.BZip2.BZip2OutputStream(或SharpZipLib库中其他压缩方式)或者System.IO.Compression.GZipStream来压缩数据时,需要注意在输出压缩数据之前关闭BZip2OutputStream或GZipStream,否则会导致压缩数据不完整(缺少必备的头尾信息)。

如果将不完整的压缩数据解压缩:

GZipStream会得到空输出

ICSharpCode.SharpZipLib.BZip2.BZip2InputStream会得到“bZip2 input stream end of compressed stream”

ICSharpCode.SharpZipLib.GZip.GZipInputStream会得到“unexpected eof”


原创粉丝点击