2013-01-23 127 views
0

我試圖找到一種方法來讀取壓縮文件的內容/文件名,解壓縮文件,然後創建一個文本文件,其中包含所有文件的解壓縮列表。使用7-zip閱讀壓縮文件

大部分情況並非問題,但是閱讀和使用檔案中的文件證明比應該更難。

我當前的代碼是...

var options = new Options(); 
      ICommandLineParser parser = new CommandLineParser(); 

      string strInput = "", strOutput = "", strExtract = "", strPassword = ""; 

      Console.WriteLine("parsing.."); 

      if (parser.ParseArguments(args, options)) 
      { 
       Console.WriteLine("checking..."); 
       if (string.IsNullOrEmpty(options.InputFile)) 
       { 
        Console.WriteLine("input is empty"); 
        Console.WriteLine(options.GetUsage()); 
       } 

       strInput = options.InputFile; 
       strOutput = options.OutputFile; 
       strExtract = options.ExtractFormat; 
       strPassword = options.Password; 

       ProcessStartInfo p = new ProcessStartInfo(); 
       p.FileName = "7za.exe"; 

       Console.WriteLine("x " + "-" + strExtract + " -p" + strPassword + " " + strInput + " -o" + strOutput); 
       p.Arguments = "x " + "-" + strExtract + " -p" + strPassword + " " + strInput + " -o" + strOutput; 
       p.WindowStyle = ProcessWindowStyle.Hidden; 

       Process x = Process.Start(p); 
       x.WaitForExit(); 

我已經找到了一些資源,以幫助,但到目前爲止沒有工作過。 找到的資源: http://pastebin.com/eTRE4TPP(我不明白他們是如何使用未聲明的變量,「l」,但即使將其更改爲「p」它也不起作用 http://www.dotnetperls.com/7-zip-examples(命令l看起來可以使用,但我沒看到我可以把文件名和保存它們)

任何幫助,將不勝感激。

感謝

+0

爲什麼要使用外部過程?爲什麼不使用SharpZip或DotNetZip? – Lloyd

+0

好吧,我使用7-zip命令行(由於規範和要求),所以我想它必須有一種方法來獲取和操作檔案中的文件。如果沒有,我可能不得不使用其他的東西以及7-Zip。 –

回答

-1

這是什麼特別,需要你用7Zip的?SharpZipLib可能能夠做你需要什麼。

相關問題