如何从7z commandLine进程获取扩展错误信息

Han*_*nan 2 c# 7zip

在我的C#app中,我运行一个7z进程将存档提取到它的目录中

例如,存档位于%TEMP%目录中的随机命名目录中

C:\ Documents and Settings\User\Local Settings\Temp\_ vtugoyrc.fd2

(fullPathFilename ="C:\ Documents and Settings\User\Local Settings\Temp\_ vtugoyrc.fd2\xxx.7z")

我的代码是:

sevenZipProcessInfo.FileName = SEVEN_ZIP_EXECUTABLE_PATH;
sevenZipProcessInfo.Arguments = "x " + fullPathFilename;
sevenZipProcessInfo.WindowStyle = ProcessWindowStyle.Hidden;
sevenZipProcessInfo.UseShellExecute = true;
sevenZipProcessInfo.WorkingDirectory = Path.GetDirectoryName(fullPathFilename);
Process sevenZipProcess = Process.Start(sevenZipProcessInfo);
if (sevenZipProcess != null)
{
    sevenZipProcess.WaitForExit();
    if (sevenZipProcess.ExitCode != 0)
         ...exit code is 2 (fatal error by the 7z help)
Run Code Online (Sandbox Code Playgroud)

我在哪里可以找到更详细的文档?

Eoi*_*ell 5

您在这里使用7 Zip作为外部进程.它相当于直接从命令行调用命令.

您是否考虑使用实际的库来压缩/解压缩文件.你可以在C#项目中引用的东西.

Sharp Zip Lib相当知名,但是它是一个特定的包装库,用于使用7zip存档