public static void DoRAR(string rarFile, string toRarDirecotry, string RARProgramFilePath)
{
string arguments = @"a -m0 -ep1 ""{0}"" ""{1}""";
arguments = string.Format(
arguments,
rarFile,
toRarDirecotry
);
var proc = Process.Start(new ProcessStartInfo
{
FileName = RARProgramFilePath,
Arguments = arguments,
UseShellExecute = false,
RedirectStandardOutput = true,
RedirectStandardError = true,
RedirectStandardInput = true
}
);
proc.WaitForExit();
if (proc.ExitCode != 0)
{
throw new Exception("Run WinRAR RAR Command Failed!, Exit Code: " + proc.ExitCode +
", Details StandardOuput: " + proc.StandardOutput.ReadToEnd() +
",StandardError" + proc.StandardError.ReadToEnd() +
",StandardInput" + proc.StandardInput +
",Site" + proc.Site);
}
}