2010-06-18 3 views

답변

6

직접적인 예를 찾을 지 모르지만 지나치게 어렵지는 않습니다. 나는 당신을 위해 모든 코드를 작성하는 시간이 없어,하지만 난 MSDN에서 당신에게 코드를 제공 할 수 있습니다

Process myProcess = new Process(); 

ProcessStartInfo myProcessStartInfo = 
    new ProcessStartInfo("C:\\MyBatchFile.bat"); 
myProcessStartInfo.UseShellExecute = false; 
myProcessStartInfo.RedirectStandardOutput = true; 

myProcess.StartInfo = myProcessStartInfo; 
myProcess.Start(); 

StreamReader myStreamReader = myProcess.StandardOutput; 

// Read the standard output of the spawned process. 
string myString = myStreamReader.ReadToEnd(); 

myProcess.Close(); 

// Now you have the output of the batch file in myString 
+0

나는 'myStreamReader.ReadToEnd();'을 제안 하겠지만 단색 +1을 제안했다. ;) – Lance

+0

@ Lance May - 게시하기 전에 변경하기로했습니다. MSDN이 원래 사용했던 것입니다. 나는 갱신을했다. –

1

여기이 answer를 참조하십시오.

출력으로 이벤트를 리디렉션하는 방법을 보여줍니다. 그런 다음 출력을 가져 와서 승 컨트롤에 넣을 수 있습니다.

관련 문제