净zlib的膨胀与.net 4.5 [英] .Net zlib inflate with .Net 4.5

查看:123
本文介绍了净zlib的膨胀与.net 4.5的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

据MSDN中的.Net 4.5 System.IO.Com pression是基于zlib的。照片 我想现在从非.NET服务器到BCL基础的实施改变我目前的互操作基础的阅读从zlib的放气流。
我的实现看起来是这样的:

According to MSDN in .Net 4.5 System.IO.Compression is based on zlib.
I am trying now to change my current interop based reading from a zlib deflated stream from a non .NET server into a BCL based implementation.
My implementation looks like this:

    var enc = new UTF8Encoding();            
        var readBytes = BufferSizeRaw;
        var outputBuffer = new byte[BufferSizeRaw];            
        var networkBuffer = _networkQueue.Take();
        var ms = new MemoryStream(networkBuffer.InputBuffer, 0, networkBuffer.UsedLength);
        using (Stream stream = new DeflateStream(ms, CompressionMode.Decompress))
            while (readBytes==BufferSizeRaw)
            {
                readBytes = stream.Read(outputBuffer, 0, outputBuffer.Length);                
                stringBuffer+= enc.GetString(outputBuffer, 0, readBytes);                
            }

我收到关于DECOM $第一次调用以下异常p $ pssion /读取的DeflateStream:

I receive the following exception on the first call of the decompression/read on the DeflateStream :

块长度不与它的互补匹配

Block length does not match with its complement

在基于互操作调用使用 VAR的结果=膨胀(REF zStyream,ZLibFlush.NoFlush;
有没有人试过相同或code看到一个原因的错误或者是有一个错误的认识,在我结束? 我也试图与截断前两个字节,没有任何运气。
的前几个字节是20,202,177,13

The interop based call uses var result=inflate(ref zStyream, ZLibFlush.NoFlush;
Has anyone tried the same or sees a reason for an error in the code or is there a wrong understanding on my end? I have also tried it with truncating the first two bytes without any luck.
The first few bytes are 20, 202, 177,13.

推荐答案

什么是你试图COM preSS?

What are the first several bytes of the data you are trying to compress?

您可能有ZLIB,GZIP,或者说你想脱code生放气数据。

You might have zlib, gzip, or raw deflate data that you're trying to decode.

顺便说一句,我强烈建议您使用 DotNetZip的接口为zlib,而不是NET 4.5的(或净任何版本)。 NET 4.5在该界面的bug,微软已经宣布,他们不会解决(!)。

By the way, I highly recommend that you use DotNetZip's interface to zlib instead of NET 4.5's (or NET any version). NET 4.5 has bugs in that interface that Microsoft has declared that they won't fix (!).

这篇关于净zlib的膨胀与.net 4.5的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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