净zlib的膨胀与.net 4.5

编程入门 行业动态 更新时间:2024-10-22 11:40:04
本文介绍了净zlib的膨胀与 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

本文发布于:2023-11-12 20:28:09,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1582456.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:zlib   net

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!