백그라운드에서 실행중인 배치 파일의 출력을 WinForms 컨트롤의 종류로 리디렉션하는 WinForms 앱의 C# 예제 프로젝트를 찾고 있습니다.배치 파일에서 출력을 보여주는 C# WinForms 앱의 예를 찾으십시오.
제안 사항?
백그라운드에서 실행중인 배치 파일의 출력을 WinForms 컨트롤의 종류로 리디렉션하는 WinForms 앱의 C# 예제 프로젝트를 찾고 있습니다.배치 파일에서 출력을 보여주는 C# WinForms 앱의 예를 찾으십시오.
제안 사항?
직접적인 예를 찾을 지 모르지만 지나치게 어렵지는 않습니다. 나는 당신을 위해 모든 코드를 작성하는 시간이 없어,하지만 난 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
여기이 answer를 참조하십시오.
출력으로 이벤트를 리디렉션하는 방법을 보여줍니다. 그런 다음 출력을 가져 와서 승 컨트롤에 넣을 수 있습니다.
나는 'myStreamReader.ReadToEnd();'을 제안 하겠지만 단색 +1을 제안했다. ;) – Lance
@ Lance May - 게시하기 전에 변경하기로했습니다. MSDN이 원래 사용했던 것입니다. 나는 갱신을했다. –