命令行调用rar,解压缩文件
来源:互联网 发布:苹果修改手机型号软件 编辑:程序博客网 时间:2024/05/05 16:43
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(); }