Reputation: 743
I have the following problem. I run an exe but i can't see in my console application everything that the exe contains. I've expected to see in the console application at least the text i am writing in the running executable. where am i wrong?
1) how can i print in the console application the text that i'm writing in the exe that i run? is that possible? i would also like to use tje standard input stream. I mean I would like to read from the exe and also write in the exe using my application.Here is the code:
Need some help. Thx!
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);
}
Upvotes: 0
Views: 1127
Reputation: 174309
The Standard*
streams are only applicable to console applications. You are running notepad, which is not a console application.
Upvotes: 3