public string winRAR(string dirPath, string zipPath, string smarkPath, string defaultValue) { try { Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\WinRAR.exe"); string WinRarPath = key.GetValue("").ToString(); if (!WinRarPath.Equals("")) { System.Diagnostics.Process Process1 = new System.Diagnostics.Process(); Process1.StartInfo.FileName = "Winrar.exe"; Process1.StartInfo.CreateNoWindow = true; string SFXPath = key.GetValue("Path").ToString() + "\\Wtwsm.SFX"; if (System.IO.File.Exists(SFXPath)) { Process1.StartInfo.Arguments = "a -r -ep1 " + zipPath + " -s -ibck -z" + smarkPath + " -sfx " + SFXPath + " " + dirPath.Trim(); } else { Process1.StartInfo.Arguments = "a -r -ep " + "\"" + zipPath + "\"" + " -s -ibck -z" + smarkPath + " -sfx " + "\"" + dirPath.Trim() + "\""; } Process1.Start(); if (Process1.HasExited) { int iExitCode = Process1.ExitCode; if (iExitCode == 0) { return defaultValue; } else return "Error"; } else return "Error"; } else return "Error"; } catch (Exception ex) { return ex.Message; } }
就是下面这个命令行搞不清楚不知道怎么配置,安装过WinRAR会有帮助文档,但是没整出来,求大神?
Process1.StartInfo.Arguments = "a -r -ep " + "\"" + zipPath + "\"" + " -s -ibck -z" + smarkPath + " -sfx " + "\"" + dirPath.Trim() + "\"";
把反斜杠转义字符去掉在最后面加上\\就可以了