【发布时间】:2013-05-09 15:07:39
【问题描述】:
我正在尝试从 winform 应用程序中解压缩文件。 我正在使用此代码:
string dezarhiverPath = @AppDomain.CurrentDomain.BaseDirectory + "\\7z.exe";
ProcessStartInfo pro = new ProcessStartInfo();
pro.WindowStyle = ProcessWindowStyle.Hidden;
pro.FileName = dezarhiverPath;
pro.Arguments = @" e c:\TEST.ZIP";
Process x = Process.Start(pro);
x.WaitForExit();
代码不返回错误但什么也没返回。 我也从 cmd 尝试了这个命令:
K:\>"C:\Test\7z.exe" e "c:\TEST.ZIP"
但在 cmd 中,我收到此错误消息:
7-Zip cannot find the code that works with archives.
有人可以帮我从 c# 中解压缩一些文件吗?
谢谢!
【问题讨论】:
-
我可以在命令行上成功运行你的命令
-
@Jack 不正确。注意字符串前面的
@符号。 stackoverflow.com/questions/5179389/at-sign-in-file-path-string -
我在 Win XP 上使用 7z.exe 的 4.65.0.0 版本。你用的是什么版本?
-
我看到的一个问题是 AppDomain.CurrentDomain.BaseDirectory 包含一个尾随“\\”,因此您应该从“\\7z.exe”中删除“\\”。