我正在尝试使用ZLib.Net
库解压缩字节数组。不幸的是,我的函数总是只返回两个字节。压缩数组有1240个字节。 zlibConst
值中没有一个确实返回超过两个字节。
ZLib.Net
可能有问题吗? (该DLL取自此处:http://zlibnet.codeplex.com/)
byte[] Decompress(byte [] compressed)
{
byte[] rez = new byte[compressed.Length];
MemoryStream oInStream = new MemoryStream(compressed);
ZInputStream oZInstream = new ZInputStream(oInStream, zlibConst.Z_BEST_COMPRESSION);
MemoryStream oOutStream = new MemoryStream();
byte[] buffer = new byte[2000];
int len;
while ((len = oZInstream.read(buffer, 0, 2000)) > 0)
{
oOutStream.Write(buffer, 0, len);
}
oOutStream.Flush();
byte[] arrUncompressed = oOutStream.ToArray();
oZInstream.Close();
oOutStream.Close();
return arrUncompressed;
}