2013-02-25 1 views

ответ

1

Вы можете захватить стандартную команду. Из MSDN documentation:

// Start the child process. 
Process p = new Process(); 
// Redirect the output stream of the child process. 
p.StartInfo.UseShellExecute = false; 
p.StartInfo.RedirectStandardOutput = true; 
p.StartInfo.FileName = "Write500Lines.exe"; 
p.Start(); 
// Do not wait for the child process to exit before 
// reading to the end of its redirected stream. 
// p.WaitForExit(); 
// Read the output stream first and then wait. 
string output = p.StandardOutput.ReadToEnd(); 
p.WaitForExit(); 

Так, читая StandardOutput (и/или StandardError) вы можете перехватывать вывод процесса вы только что запустили.

+0

Спасибо за ответ. Хотя я получаю Console.WriteLine, я не могу извлечь информацию Trace.WriteLine. Я не уверен, что это возможно. – sessionista

Смежные вопросы