fastest way to extract .zip archive

。_饼干妹妹 提交于 2020-04-13 06:26:07

问题


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.


回答1:


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 also ZipFile, 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.




回答2:


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:

    private static void ExtractWith7Zip(string archivePath, string extractPath)
    {
        var info = new ProcessStartInfo
        {
            FileName = @"C:\Program Files\7-Zip\7z.exe",
            Arguments = $"x -y -o\"{extractPath}\" \"{archivePath}\"",
            WindowStyle = ProcessWindowStyle.Hidden,
            CreateNoWindow = true,
            UseShellExecute = false,
            RedirectStandardOutput = true
        };

        Process.Start(info)?.WaitForExit();
    }



回答3:


use DotNetZip library, you can extract all file just using ExtractAll() method :)




回答4:


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.



来源:https://stackoverflow.com/questions/5647910/fastest-way-to-extract-zip-archive

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!