7-Zip 7za 命令行找不到指定文件
我有使用 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
“嵌入资源”只能与 .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 whatProcess.Start
uses).