可以的GZip COM pression(通过.NET)增加文件大小?文件大小、COM、GZip、NET

2023-09-05 02:04:46 作者:野性而又干净

我跟踪我是COM pressing使用。NET的GZipStream类文件的原始大小,而且好像,我认为我是COM pressing的规模增加了文件。这可能吗?

这是我如何做COM pression:

 字节[]字节= GetFileBytes(文件);

使用(的FileStream FILESTREAM =新的FileStream(Zipped.gz,FileMode.Create))
{
    使用(GZipStream zipStream =新GZipStream(FILESTREAM,COM pressionMode.Com preSS))
    {
        zipStream.Write(字节,0,bytes.Length);
    }
}
 

解决方案

是的,它可以。它一直固定在.NET 4 。

  

在COM pression算法的System.IO.Com pression .. ::。DeflateStream和System.IO.Com pression .. ::。GZipStream类有这样的数据提高了已经融为一体pressed不再膨胀。这将导致更好的融为一体pression比率。此外,4 GB的大小限制COM pressing流已被删除。

检查: GZipStream / DeflateStream增加文件的COM pression

另外,请在这里SO:GZipStream和DeflateStream产生较大的文件

IIS FastCGI PHP5.3 MySQL5.1 Gzip配置图文详细教程

I keep track of the original size of the files that I'm compressing using .Net's GZipStream class, and it seems like the file that I thought I was compressing has increased in size. Is that possible?

This is how I'm doing the compression:

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);
    }
}

解决方案

Yes, it can. It has been 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.

Check: GZipStream/DeflateStream increase file size on compression

Also check here SO: GZipStream and DeflateStream produce bigger files