为什么我在使用 DeflateStream 解压和压缩回字节数组后没有得到相同的内容?
编码:
byte[] originalcontent = Same Byte Array Content
byte[] decompressedBytes;
byte[] compressedBackBytes;
// Decompress the original byte-array
using (Stream contentStream = new MemoryStream(originalcontent, false))
using (var zipStream = new DeflateStream(contentStream, CompressionMode.Decompress))
using (var decStream = new MemoryStream())
{
zipStream.CopyTo(decStream);
decompressedBytes = decStream.ToArray();
}
// Compress the byte-array back
using (var input = new MemoryStream(decompressedBytes, true))
using (var compressStream = new MemoryStream())
using (var compressor = new DeflateStream(compressStream, CompressionMode.Compress))
{
input.CopyTo(compressor);
compressedBackBytes = compressStream.ToArray();
}
为什么 originalcontent != compressedBackBytes ?