2014-11-09 1 views
0

콘솔 입력을 WPF 응용 프로그램 내부에서 가져 오려고합니다. 프로젝트 속성에서 콘솔 응용 프로그램으로 설정하고 출력물이 작동합니다. 그러나 지금은보기에서 작업을 시작하지 않았으므로 콘솔에서 입력을 읽을 수 있어야합니다. 여기에이 조각을 발견,하지만 난 그게 내가 찾던 무엇을 믿지 않는다 :콘솔 입력 WPF 응용 프로그램 내부

Process compiler = new Process(); 
compiler.StartInfo.FileName = "C:\\Windows\\Microsoft.NET\\Framework64\\v4.0.30319\\csc.exe"; 
compiler.StartInfo.Arguments = "/r:System.dll /out:sample.exe stdstr.cs"; 
compiler.StartInfo.UseShellExecute = false; 
compiler.StartInfo.RedirectStandardOutput = true; 
compiler.Start(); 

Console.WriteLine(compiler.StandardOutput.ReadToEnd()); 

compiler.WaitForExit(); 

답변

1

이유는 단순히 Console.ReadLine()를 사용할 수 있습니까?

string userInput = Console.ReadLine(); 
+0

콘솔 앱이 아닙니다. 콘솔을 처리하는 다른 스레드가 있어야합니다. – keelerjr12

+0

@ keelerjr12 : 콘솔 응용 프로그램의 시작 개체를 설정 했습니까? – grovesNL

+0

@ keelerjr12 : 나는 당신이 무엇을하려고하는지 정확히 이해하지 못한다고 생각합니다. 나는 WPF 프로젝트를 만들고, 출력 유형을 'Console Application'으로 설정하고, Console.ReadLine()은 저에게 잘 동작합니다. –

관련 문제