private void CompilePascal(string SourceFile, string OutputFile, ProgrammingLanguages PL, string WorkingDirectory = null) { if (PL != ProgrammingLanguages.Pascal && PL != ProgrammingLanguages.Delphi && PL != ProgrammingLanguages.ObjPas && PL != ProgrammingLanguages.TurboPas) { throw new NotSupportedException(); } ProcessStartInfo startInfo = new ProcessStartInfo(); startInfo.UseShellExecute = false; startInfo.RedirectStandardError = true; startInfo.RedirectStandardOutput = true; startInfo.FileName = Compilers.GetPath(PL); startInfo.Arguments = Compilers.GetOptions(PL) + " \"" + SourceFile + "\" -o\"" + OutputFile + "\""; startInfo.CreateNoWindow = true; if (WorkingDirectory != null) { startInfo.WorkingDirectory = WorkingDirectory; } string error = ""; using (Process proc = Process.Start(startInfo)) { error += proc.StandardError.ReadToEnd(); error += proc.StandardOutput.ReadToEnd(); proc.WaitForExit(); logger.Debug("Compilation of file \"{0}\" end", Path.GetFileName(SourceFile)); if (logger.IsDebugEnabled) { Console.WriteLine(DateTime.Now.ToString(culture) + " - Compilation of file \"{0}\" end", Path.GetFileName(SourceFile)); } if (proc.ExitCode != 0) { throw new InvalidDataException(error); } } }