可以的GZip COM pression(通过.NET)增加文件大小? [英] Can GZip compression (via .net) increase file size?
问题描述
我跟踪我是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流已被删除。
检查:<一href="http://connect.microsoft.com/VisualStudio/feedback/details/93636/gzipstream-deflatestream-increase-file-size-on-com$p$pssion"相对=nofollow> GZipStream / DeflateStream增加文件的COM pression
另外,请在这里SO:<一href="http://stackoverflow.com/questions/3864055/gzipstream-and-deflatestream-produce-bigger-files">GZipStream和DeflateStream产生较大的文件
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
这篇关于可以的GZip COM pression(通过.NET)增加文件大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!