首页 新闻 会员 周边

C# WinRAR自解压

-1
[已解决问题] 解决于 2018-05-23 23:14
       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() + "\"";
爱编程1314的主页 爱编程1314 | 初学一级 | 园豆:26
提问于:2017-04-25 14:02
< >
分享
最佳答案
0

把反斜杠转义字符去掉在最后面加上\\就可以了

爱编程1314 | 初学一级 |园豆:26 | 2017-05-02 09:46
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册