我想默默摘录.rar
档案。 .Net 在 IO.Compression 中没有任何 Rar 类,所以我想使用 cmd (它比外部 dll 更好)。它会提取,但不在静默模式下提取。我究竟做错了什么?
const string source = "D:\\22.rar";
string destinationFolder = source.Remove(source.LastIndexOf('.'));
string arguments = string.Format(@"x -s ""{0}"" *.* ""{1}\""", source, destinationFolder);
Process.Start("winrar", arguments);
我自己使用这段代码(添加了您的代码):
const string source = "D:\\22.rar";
string destinationFolder = source.Remove(source.LastIndexOf('.'));
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.CreateNoWindow = true;
p.StartInfo.UseShellExecute = false;
p.StartInfo.FileName = "\"C:\\Program Files\\WinRAR\\winrar.exe\"";
p.StartInfo.Arguments = string.Format(@"x -s ""{0}"" *.* ""{1}\""", source, destinationFolder);
p.Start();
p.WaitForExit();
这将在后台启动 WinRAR 程序,并在文件完成解压缩后将控制权返回给您。
希望能有所帮助
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)