[英]How do I retrieve only one specific file from a 7z instead of unzipping and dumping to a folder?
[英]how to get extended error information from 7z commandLine process
在我的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众所周知,但是这里有一个使用7zip存档的特定包装库
感谢所有帮助。
无论如何,问题是使用“长路径名”->命令行过程找不到C:\\ Documents and Settings \\(由于名称中有空格)。 解决方案可以在这里找到在.net中转换为短路径的标准方法
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.