string the_rar;
RegistryKey the_Reg;
object the_Obj;
string the_Info;
try
{
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();
if (Directory.Exists(unRarPatch) == false)
{
Directory.CreateDirectory(unRarPatch);
}
the_Info = "x " + rarPatch +"\\"+ rarName + " " + unRarPatch + " -y";
ProcessStartInfo the_StartInfo = new ProcessStartInfo();
the_StartInfo.FileName = the_rar;
the_StartInfo.Arguments = the_Info;
the_StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
//獲取壓縮包路徑
the_StartInfo.WorkingDirectory = rarPatch;
Process the_Process = new Process();
the_Process.StartInfo = the_StartInfo;
the_Process.Start();
the_Process.WaitForExit();
the_Process.Close();
new Normal_AdminlogsDAL().SaveMapServiceLog(unRarPatch + " ? " + rarPatch + " ? " + rarName );//Test
new Normal_AdminlogsDAL().SaveMapServiceLog(the_Info + " ? " + the_rar);//Test
}
catch (Exception ex)
{
new Normal_AdminlogsDAL().SaveMapServiceLog(" 解壓發生異常:" + ex.Message);
}
你這個不是寫了一個解壓文件,只是簡單調用了winrar,你看下你的參數對不對,先在命令行中運行下。