private static void Call(string arguments) { if (!Archive2.ValidatePath()) { throw new Archive2Exception("Path to Archive2.exe not specified or Archive2.exe not found."); } using (Process proc = new Process()) { LogFile.WriteTimeStamp(); LogFile.WriteLine($">> Archive2.exe {arguments}"); proc.StartInfo.UseShellExecute = false; // = true proc.StartInfo.RedirectStandardOutput = true; // // ... proc.StartInfo.RedirectStandardError = true; // // ... proc.StartInfo.FileName = Archive2.archive2Path; proc.StartInfo.Arguments = arguments; proc.StartInfo.CreateNoWindow = true; // // ... proc.Start(); //MessageBox.Show(/*proc.StandardOutput.ReadToEnd(), */$"Archive2.exe {arguments}"); /*logFile.WriteLine(proc.StandardOutput.ReadToEnd()); * logFile.WriteLine(proc.StandardError.ReadToEnd());*/ string output = proc.StandardOutput.ReadToEnd() + "\n" + proc.StandardError.ReadToEnd(); LogFile.WriteLine(output); proc.WaitForExit(); // System.IO.FileNotFoundException: Could not load file or assembly 'Archive2Interop.dll' if (output.Contains("System.IO.FileNotFoundException:") && output.Contains("'Archive2Interop.dll'")) { throw new Archive2RequirementsException("System.IO.FileNotFoundException: Could not load file or assembly 'Archive2Interop.dll'. 'Visual C++ Redistributable for Visual Studio 2012 Update 4' is likely not installed."); } } }
private static void CallParallel(string arguments) { if (!Archive2.ValidatePath()) { throw new Archive2Exception("Path to Archive2.exe not specified or Archive2.exe not found."); } using (Process proc = new Process()) { proc.StartInfo.UseShellExecute = false; proc.StartInfo.FileName = Archive2.archive2Path; proc.StartInfo.Arguments = arguments; proc.StartInfo.CreateNoWindow = true; proc.Start(); } }