gpt4 book ai didi

.net - GZip 压缩(通过 .net)会增加文件大小吗?

转载 作者:行者123 更新时间:2023-12-01 13:04:21 27 4
gpt4 key购买 nike

我使用 .Net 的 GZipStream 类跟踪我正在压缩的文件的原始大小,我认为我正在压缩的文件似乎增加了大小。这可能吗?

这就是我进行压缩的方式:

Byte[] bytes = GetFileBytes(file);

using (FileStream fileStream = new FileStream("Zipped.gz", FileMode.Create))
{
using (GZipStream zipStream = new GZipStream(fileStream, CompressionMode.Compress))
{
zipStream.Write(bytes, 0, bytes.Length);
}
}

最佳答案

是的,它可以。已经fixed in .NET 4 .

The compression algorithms for the System.IO.Compression..::.DeflateStream and System.IO.Compression..::.GZipStream classes have improved so that data that is already compressed is no longer inflated. This results in much better compression ratios. Also, the 4-gigabyte size restriction for compressing streams has been removed.

检查:GZipStream/DeflateStream increase file size on compression

另请在此处查看 SO:GZipStream and DeflateStream produce bigger files

关于.net - GZip 压缩(通过 .net)会增加文件大小吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3973485/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com