C++ 的compress压缩中先用compressBound计算压缩长度。
请问对应的C#中用哪个库压缩和解压缩?
public static byte[] DeCompress(byte[] source)
{
//return CommonCompressor.Compress(CreateStream, source);
List<byte> tmpArray = new List<byte>();
int data = 0;
int stopByte = -1;
using (MemoryStream ms = new MemoryStream(source))
{
using (ZInputStream inZStream = new ZInputStream(ms))
{
while (stopByte != (data = inZStream.Read()))
{
tmpArray.Add((byte)data);
}
}
}
return tmpArray.ToArray();
}
public static byte[] Compress(byte[] source)
{
//return CommonCompressor.Compress(CreateStream, source);
byte[] tmpArray;
using (MemoryStream ms = new MemoryStream())
{
using (ZOutputStream outZStream = new ZOutputStream(ms, zlibConst.Z_DEFAULT_COMPRESSION))
{
outZStream.Write(source, 0, source.Length);
outZStream.Flush();
}
tmpArray = ms.ToArray();
}
return tmpArray;
}
C#压缩与解压缩, C++与C#压缩结果不一样,但是C#都可以解压
如果是使用的zlib的话,在c# 使用GZipStream可以进行解压缩,其他压缩库的话,你就得找找对应的。