C#使用7zip获取存档中的文件列表?

buz*_*jay 4 c# 7zip visual-studio-2010

我在C#程序中使用7zip http://www.7-zip.org/download.html使用下面的代码解压缩文件.

Process t = new Process();
t.StartInfo.FileName = "7za.exe";
t.StartInfo.Arguments = "e " + filePath[i] + " -y -o" + directory[3];
t.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
t.EnableRaisingEvents = true;
t.StartInfo.UseShellExecute = false;
l.StartInfo.RedirectStandardOutput = true;
t.Start();
Console.WriteLine(l.StandardOutput.ReadToEnd());
t.WaitForExit();
Run Code Online (Sandbox Code Playgroud)

我发现在7zip帮助中搜索可以使用l而不是e(第3行)来列出存档的内容,但我无法弄清楚如何获取存档中包含的文件的文件名.有任何想法吗?谢谢!

SLa*_*aks 6

您应该使用7zip SDKSevenZipSharp.

要回答您的问题,请设置RedirectStandardOutput为true,然后阅读t.Output.