gpt4 book ai didi

c# - 如何从 7z 命令行进程获取扩展错误信息

转载 作者:行者123 更新时间:2023-11-30 20:14:40 31 4
gpt4 key购买 nike

在我的 C# 应用程序中,我运行一个 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)

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

最佳答案

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

您是否考虑过使用实际的库来压缩/解压缩文件。您可以在 C# 项目中引用的内容。

Sharp Zip Lib是众所周知的,但这是一个特定的 wrapper library使用 7zip 存档

关于c# - 如何从 7z 命令行进程获取扩展错误信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/258198/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com