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看起来可以使用,但我没看到我可以把文件名和保存它们)
任何帮助,将不胜感激。
感谢
为什么要使用外部过程?为什么不使用SharpZip或DotNetZip? – Lloyd
好吧,我使用7-zip命令行(由于规范和要求),所以我想它必须有一种方法来获取和操作档案中的文件。如果没有,我可能不得不使用其他的东西以及7-Zip。 –