最好的 .NET Framework 压缩类?
是的,我知道 GZipStream 或 DeflateStream 是 .NET Framework 中处理压缩/解压缩的常见工具。
我希望在我的程序中具有压缩/解压缩功能,但是
我希望使用 .NET Framework C# 功能,而不是第 3 方开源软件。由于程序中的版权限制,我无法使用。
GZipStream 和 DeflateStream 不太好。例如,GZipStream 将文件压缩到 480KB,而 7Zip 将同一文件压缩到 57KB。
微软还有其他好的压缩方法吗???
谢谢
Yes, I know GZipStream or DeflateStream is the common ones in .NET Framework which handle compression/decompression.
I wish to have compress/decompress functions in my program, but
I wish a .NET Framework C# one, not a 3rd party open source. I can't use because of those copyright restrictions in my program.
GZipStream and DeflateStream are not so good. for e.g., GZipStream compress a file to 480KB while 7Zip compress the same file to the size of 57KB.
Does Microsoft have other good compression methods???
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
GZipStream 和 DeflateStream 专门用于压缩流,而不是用于存储的一般文件压缩。
除了这些类之外,.NET 中并未内置压缩。如果你想要高质量的压缩,你将不得不去第三方库。查看 http://www.7-zip.org/sdk.html 获取开源 7zip 库。
GZipStream and DeflateStream are specifically intended for compressed streams, not general compression of files for storage.
Other than those classes, compression is not built into .NET. If you want high-quality compression you will have to go to a third party library. Check out http://www.7-zip.org/sdk.html for an open-source 7zip library.
7zip 有一个托管包装器。该许可证是 LGPL,因此您可以在闭源项目中使用它。我不知道这是否符合您的许可证要求,因为您没有说明。
http://sevenzipsharp.codeplex.com/
There is a managed wrapper for 7zip. The license is LGPL so you can use it in closed source projects. I do not know if this fits your license requirements as you did not state them.
http://sevenzipsharp.codeplex.com/
我没有任何有关压缩率的统计数据,但我一直在使用 SharpZipLib图书馆多年来取得了巨大成功。
I don't have any statistics regarding compression rates, but I'd been using the SharpZipLib library for years with much success.
好吧,我尝试像递归数据一样压缩,很有趣。检查我的示例:
现在,我尝试压缩太大的文件,例如:
检查缓冲区、level1 和 level2 的大小。
缓冲区大小为 77683,level1 = 57354,level2 = 8202...
缓冲区为 100%,则:
57354 是 73,83%
8202 是 10.55%
太有趣了。
Well, I try to compress like recursive data, is funny. Check my example:
Now, I try to Compress a file too big, for example:
Check the size of buffer, level1 and level2.
buffer size is 77683, level1 = 57354 and level2 = 8202...
buffer is 100%, then:
57354 is 73,83%
8202 is 10,55%
so funny.
您还可以将开源 ZLib (http://www.zlib.net/) 与 PInvoke 结合使用,或使用它的包装器(我使用过 zlib.net - http://www.componentace .com/zlib_.NET.htm - 但我相信它有一些错误)。
它不如托管库方便,但比 DeflateStream/GZipStream 更高效(除了 GZipStream 中额外的 CRC 之外,它们是相同的)。
you can also use the open source ZLib (http://www.zlib.net/) with PInvoke, or use a wrapper for it (I've used zlib.net - http://www.componentace.com/zlib_.NET.htm - but I believe it had some bugs).
it's less convenient than managed libraries, but more efficient than DeflateStream/GZipStream (which are the same except for an extra CRC in GZipStream).