我有一个使用7za.exe的C#程序,它使用"l“命令检查压缩文件,然后使用"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();示例: filePathi = C:\Users\Me\Desktop\ZipFile.zip
发布于 2011-09-13 00:46:00
“嵌入式资源”只能与Windows一起使用,它不会创建单独的文件,也不能被常规的.NET函数找到,比如CreateProcess (这就是Process.Start所使用的)。
https://stackoverflow.com/questions/7390209
复制相似问题