之前用注册表调用总是出错,所以这里直接使用winrar的绝对路径
/// <summary>
/// 利用 WinRAR 进行解压缩
/// </summary>
/// <param name="path">文件解压路径(绝对)</param>
/// <param name="rarPath">将要解压缩的 .rar 文件的存放目录(绝对路径)</param>
/// <param name="rarName">将要解压缩的 .rar 文件名(包括后缀)</param>
public void UnRAR(string path, string rarPath, string rarName)
{
ProcessStartInfo startinfo = new ProcessStartInfo(); ;
Process process = new Process();
String rarexe = @"F:\WinRAR\WinRAR.exe"; //WinRAR安装位置
//解压缩命令,相当于在要压缩文件(rarName)上点右键->WinRAR->解压到当前文件夹
String cmd = string.Format("x {0} {1} -y",rarName,path);
startinfo.FileName = rarexe;
startinfo.Arguments = cmd;
startinfo.WindowStyle = ProcessWindowStyle.Hidden;
startinfo.WorkingDirectory = rarPath;
process.StartInfo = startinfo;
process.Start();
process.WaitForExit();
process.Dispose();
process.Close();
}