提取 .zip 存档的最快方法
提取 .zip 档案的最快方法是什么?我的应用程序的性能很大程度上取决于提取 .zip 文件的速度。我正在使用 dotNetzip atm,但似乎可以有更多更快的工具。如果有,他们安全吗?我听说 QuickLZ 是最快的,但没有测试过,也没有找到任何代码示例或如何在 c# 中使用它。任何帮助将不胜感激。
Which is the fastest way for extracting .zip archives? Performance of my application is highly based on how fast .zip files are extracted. I am using dotNetzip atm, but it seems that there could be more faster tools. If there is, are they safe? I've heard that QuickLZ is the fastest, but haven't tested it, also haven't found any code samples or how to use it in c#. Any help would be greatly appriciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
使用 DotNetZip 库,您只需使用 ExtractAll() 方法即可提取所有文件:)
use DotNetZip library, you can extract all file just using ExtractAll() method :)
如果可以选择将项目升级到 .NET 4.5,则可以使用
ZipArchive
类。 我写了一篇关于使用它的文章,而且非常简单。还有ZipFile
,我也写过,甚至更轻松。不过,我无法评论性能,因为我没有使用 ZIP 存档的第三方库。If upgrading your project to .NET 4.5 is an option, then you can use the
ZipArchive
class. I wrote an article on using it, and it's dead simple. There's alsoZipFile
, which I also wrote about and is even easier. I can't comment on the performance however, because I've not used third-party libraries for ZIP archives.根据我们自己的测试,7-zip CLI(exe 文件)是迄今为止最快的。 CLI 应用程序的性能优于所有这些 .NET dll,这听起来很疯狂,但不幸的是这是事实。
准确地说,我已经使用 ZipFile 和 ZipArchive 测试了 SharpCompress、SharpZipLib、DotNetZip、.NET 自己的实现。对于我们的测试文件,所有这些程序的运行时间约为 10-20 秒,但 7-zip 的 exe 进程通常在 7-8 秒内完成。
如果您决定使用 7-zip,这里是示例代码:
Doing our own tests, 7-zip CLI (exe file) was fastest by far. It sounds crazy that a CLI application would outperform all those .NET dlls, but unfortunately it's the fact.
To be precise, I've tested SharpCompress, SharpZipLib, DotNetZip, .NET's own implementation using ZipFile and ZipArchive. All of them were running around 10-20 seconds for our test file, but 7-zip's exe process was usually finishing at 7-8 seconds.
Here is a sample code, if you decide to use 7-zip:
您的 zip 文件有多大?也许您可以利用现代多核处理器,将原始文件分成几个部分,独立压缩每个部分,然后使用多线程将它们解压缩到您的应用程序中。与解压缩时间相比,在内存中重新组合文件的时间会很短。
How large are your zip files? Perhaps you can take advantage of modern multi core processors by splitting the original file into parts, zipping each part independently and then unzipping them in your application using multithreading. The time to recombine the files in memory will be tiny compared to the unzip time.