我正在使用单声道来膨胀/缩小字节。这是代码:
public static byte[] Inflate(byte[] data)
{
using (MemoryStream inStream = new MemoryStream(data))
{
using (MemoryStream outStream = new MemoryStream())
{
using (DeflateStream decompressStream = new DeflateStream(inStream, CompressionMode.Decompress))
{
decompressStream.CopyTo(outStream);
}
return outStream.ToArray();
}
}
}
输入数据为:<789c3dca b9110020 0c04b196 bc9c3f7a 73f11030 281652d1 88b04195 1e742987 2f86258f acdec63d 6dcf0184 560cde> 47bytes。算法是 DEFLATE。
我已经成功地在其他平台上膨胀了相同的数据,但是通过上面的代码,它抛出了以下异常:
System.IO.IOException: Corrupted data ReadInternal
at System.IO.Compression.DeflateStreamNative.CheckResult (Int32 result, System.String where) [0x00000] in <filename unknown>:0
at System.IO.Compression.DeflateStreamNative.ReadZStream (IntPtr buffer, Int32 length) [0x00000] in <filename unknown>:0
at System.IO.Compression.DeflateStream.ReadInternal (System.Byte[] array, Int32 offset, Int32 count) [0x00000] in <filename unknown>:0
at System.IO.Compression.DeflateStream.Read (System.Byte[] dest, Int32 dest_offset, Int32 count) [0x00000] in <filename unknown>:0
at System.IO.Stream.CopyTo (System.IO.Stream destination, Int32 bufferSize) [0x00000] in <filename unknown>:0
at System.IO.Stream.CopyTo (System.IO.Stream destination) [0x00000] in <filename unknown>:0