2015-11-03 225 views
0

我正在編寫一個程序,它從zip文件中提取圖像並對其進行編目。解壓縮大型壓縮文件的更快方法

System.IO.Compression.ZipFile.ExtractToDirectory對於較小的文件似乎工作正常,但它確實很慢大文件(> 4GB),有更快的庫嗎?我不需要任何特別的東西來將zip文件解壓縮到目錄中。

+1

你檢查它不只是要移動的數據量:在當前實現IO約束?如果您的IO速度是限制因素,則代碼更改將會產生顯着差異。 – Richard

+0

*真的很慢* *?簡單地寫入新文件的代碼需要多長時間才能獲得相同數量的字節? – Sinatr

+0

我正在測試一個基本上包含參考文件(csv)和數千個圖像的8.9GB文件,我在今天上午10點開始了程序測試,它仍然會...... 5+小時,它已經提取了85000+到目前爲止 – franklores

回答

0

使用7-Zip http://www.7-zip.org/download.html

public static string[] UnpackZip(string file, string targetDirectory) 
    { 
     Process p = new Process(); 
     string unzip = "x -y \"-o" + targetDirectory + "\" \"" + file + "\" "; 
     p.StartInfo.FileName = "7z.exe"; 
     p.StartInfo.Arguments = unzip; 
     p.Start(); 
     p.WaitForExit(); 
     if (p.ExitCode != 0) 
      throw new Exception("Errore durante l'unzip " + p.ExitCode + " - " + unzip); 
     return Directory.GetFiles(targetDirectory); 
    } 
+0

這是否需要在機器上安裝7-zip?我解壓縮遠程服務器,不知道我將有權訪問7-zip – franklores

+1

無需安裝,只需將exe和dll放入您的exe目錄 – owairc