日期:2014-05-17  浏览次数:20760 次

解压问题
[code=csharp]public static bool StartUnRAR(string rarFile, string destinationDirectory, bool deleteRarFile)
        {
            RegistryKey regkey;
            Object regvalue;
            string cmd;
            ProcessStartInfo startinfo;
            Process process;
            string rarexe;
            try
            {
                // 如果不输入目录则释放到与压缩包同目录下
                if (destinationDirectory == null)
                {
                    destinationDirectory = Path.GetDirectoryName(rarFile);
                }



                regkey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\WinRAR.exe");
                regvalue = regkey.GetValue("");
                rarexe = regvalue.ToString();
                regkey.Close();
               // rarexe = rarexe.Substring(1, rarexe.Length - 7);//解压缩命令,相当于在要压缩文件(rarName)上点右键->WinRAR->解压到当前文件夹
                cmd = string.Format("x {0} {1} -y",
                                    rarFile,
                                    destinationDirectory);
                startinfo = new ProcessStartInfo();
                startinfo.FileName = rarexe;
                startinfo.Arguments = cmd;
                startinfo.WindowStyle = ProcessWindowStyle.Hidden;
                process = new Process();
        &