在下面的代码中,我注意到compressedBytes值是 147,它大于bytes100。
我想compressedBytes应该是少了。请建议为什么?
byte[] compressedBytes;
byte[] bytes = File.ReadAllBytes(filename); //byte[100]
using (var outStream = new MemoryStream())
{
using (var archive = new ZipArchive(outStream, ZipArchiveMode.Create, true))
{
var fileInArchive = archive.CreateEntry("test.txt", CompressionLevel.Optimal);
using (var entryStream = fileInArchive.Open())
using (var fileToCompressStream = File.Open(filename, FileMode.Open))
{
var X = fileToCompressStream.Length; //100
fileToCompressStream.CopyTo(entryStream);
}
}
compressedBytes = outStream.ToArray(); //byte[147]
}
慕妹3146593
相关分类