다음과 같은 문제가 있습니다. exe를 실행하지만 내 콘솔 응용 프로그램에서 exe가 포함 된 모든 것을 볼 수 없습니다. 콘솔 응용 프로그램에서 적어도 실행중인 실행 파일에 쓰는 텍스트를 볼 것으로 예상했습니다. 내가 어디가 잘못 됐니?C# 표준 출력 readtoEnd()
1) 콘솔 응용 프로그램에서 내가 실행중인 exe에 쓰는 텍스트를 어떻게 인쇄 할 수 있습니까? 그게 가능하니? 나는 또한 tje 표준 입력 스트림을 사용하고 싶다. 내 말은 exe에서 읽고 exe에서 내 응용 프로그램을 사용하여 작성하고 싶다는 뜻입니다. 코드는 다음과 같습니다.
도움이 필요합니다. 고마워!
static void Main(string[] args)
{
string s;
ProcessStartInfo p = new ProcessStartInfo();
p.UseShellExecute = false;
p.RedirectStandardOutput = true;
p.RedirectStandardInput = true;
p.RedirectStandardError = true;
p.FileName = @"notepad.exe";
using (Process pp = Process.Start (p))
{
string output = pp.StandardOutput.ReadToEnd();
//pp.WaitForExit();
StreamReader myStreamReader = pp.StandardError;
// finally output the string
Console.WriteLine("output is: "+output+"....."+myStreamReader.ReadLine());
// pp.Close();
Thread.Sleep (2000);
}
메모장에 쓴 텍스트를 콘솔에 덤프하려고합니까? –
정확히 무엇을 하려는지 구체적으로 설명해 주시겠습니까? 왜 별도의 프로세스가 필요한가요? – GregC
Notepad.exe가 표준 출력이나 표준 오류에 기록하는지 모르겠습니다 ... 명령 줄 프로그램이 아니라 GUI 프로그램입니다. –