7-Zip 7za 命令行找不到指定文件

发布于 2024-12-04 16:25:04 字数 901 浏览 6 评论 0原文

我有使用 7za.exe 的 C# 程序,使用“l”命令检查 zip 存档,然后使用“e”命令提取它。有关 7-Zip 命令行的信息可以在以下位置找到: http://www.dotnetperls.com/7 -zip-examples

我可以从服务器上的桌面运行该程序,它运行得很好,但是直接在服务器上运行它会出现以下异常:“系统找不到指定的文件”。我已验证文件路径是否正确并且正在传递给 7za.exe。我已将 7za.exe 作为嵌入式资源附加到我的项目中,但不确定为什么找不到这些文件?有什么想法吗?谢谢!

这是我必须验证是否可以打开 zip 存档的代码,除了 l 是 e 之外,大部分与解压缩相同。

Process l = new Process();
l.StartInfo.FileName = "7za.exe";
l.StartInfo.Arguments = "l " + filePath[i];
l.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
l.EnableRaisingEvents = true;
l.StartInfo.UseShellExecute = false;
l.StartInfo.RedirectStandardOutput = true;
l.Start(); // This is were it throuws the exception because it can't find the file.
// Do stuff to verify zip archive is not corrupt
l.WaitForExit();

例如: filePath[i] = C:\Users\Me\Desktop\ZipFile.zip

I have C# program using 7za.exe to check a zip archive using the "l" command and then extract it using the "e" command. Information about 7-Zip command line can be found at: http://www.dotnetperls.com/7-zip-examples

I can run the program from my desktop on the sever and it works great, however running it directly on the server it gives the following exception: "The system cannot find the file specified". I have verified that the file path is correct and is being passed to 7za.exe. I have attached 7za.exe as an Embedded Resource in my project and not sure why it can't find the files? Any ideas? Thanks!

Here is the code I have to verify I can open the zip archive and mostly the same to unzip except the l is an e.

Process l = new Process();
l.StartInfo.FileName = "7za.exe";
l.StartInfo.Arguments = "l " + filePath[i];
l.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
l.EnableRaisingEvents = true;
l.StartInfo.UseShellExecute = false;
l.StartInfo.RedirectStandardOutput = true;
l.Start(); // This is were it throuws the exception because it can't find the file.
// Do stuff to verify zip archive is not corrupt
l.WaitForExit();

Ex: filePath[i] = C:\Users\Me\Desktop\ZipFile.zip

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梨涡少年 2024-12-11 16:25:04

“嵌入资源”只能与 .NET 资源 API 一起使用,它不会创建单独的文件,也无法被普通的 Windows 函数找到,例如 CreateProcess (这就是 >Process.Start 使用)。

The "embedded resource" can only be used with the .NET resource API, it doesn't create individual files and can't be found by normal Windows functions, such as CreateProcess (which is what Process.Start uses).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文