您的位置:首页 > 其它

命令行调用rar,解压缩文件

2013-06-07 17:25 197 查看
public void UnCompressPackage(string PackagePhysicalFullPath)
        {
            //压缩文件存在的目录
            string RARFilePath = Path.GetDirectoryName(PackagePhysicalFullPath);

            //解压到文件夹
            string UnRARFilePath = Path.Combine(RARFilePath, Path.GetFileNameWithoutExtension(PackagePhysicalFullPath));
            Directory.CreateDirectory(UnRARFilePath);
            //解压缩
            String the_rar;
            RegistryKey the_Reg;
            Object the_Obj;
            String the_Info;
            ProcessStartInfo the_StartInfo;
            Process the_Process;

            the_Reg = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\WinRAR.exe");
            the_Obj = the_Reg.GetValue("");
            the_rar = the_Obj.ToString();
            the_Reg.Close();
            the_Info = @" X " + " " + PackagePhysicalFullPath + " " + UnRARFilePath + " -y";
            the_StartInfo = new ProcessStartInfo();
            the_StartInfo.FileName = the_rar;
            the_StartInfo.Arguments = the_Info;
            the_StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
            the_Process = new Process();
            the_Process.StartInfo = the_StartInfo;
            the_Process.Start();
            the_Process.WaitForExit();
            the_Process.Close();
        }
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: