Take the 2-minute tour ×

I have code that looks more or less like the code below but it doesn't retrieve text from the application I'm opening (notepad). Maybe I'm missing the point. Can someone explain what a Standard Output Stream is and whether in fact it's what I want to use if I want to open an application and then retrieve the text it displays?

ProcessStartInfo psi = new ProcessStartInfo("notepad.exe", "c:\\test.txt");
psi.RedirectStandardOutput = true;
psi.UseShellExecute = false;

Process p = new Process();
p.StartInfo = psi;

string s = p.StandardOutput.ReadToEnd();
share|improve this question
StandardOutput is what is is written to the console. The various output streams are for command-line style programs. You will not be able to capture Notepad output via this method. –  Joe Jun 13 '12 at 0:43
In addition, Windows GUI applications don't have "output" like that, anyway. What exactly are you trying to accomplish? –  Ken White Jun 13 '12 at 0:47
add comment

3 Answers

up vote 1 down vote accepted

There are three standard streams input output and error. They are mostly used by console programs to send in put and out put to each other. notepad is a gui program and notion of standard out and standard in don't really map. A example of usage would be dir | fndstr hi in this case the command dir sends its out put to the standard input of fndstr.

share|improve this answer
Minor correction: They are mostly used to receive input and send output, not necessarily "to each other". Printing to the console and receiving input from the keyboard are perfectly common uses of stdin and stdout. –  Ken White Jun 13 '12 at 0:49
add comment

From the Wikipedia article:

In computer programming, standard streams are preconnected input and output channels between a computer program and its environment (typically a text terminal) when it begins execution. The three I/O connections are called standard input (stdin), standard output (stdout) and standard error (stderr).

As mentioned by Joe, the information written to standard in and out are typically chained together between console applications. The text displayed in windows applications does not typically follow this pattern, though they do have the 3 standard streams available to them, they just usually don't write to them.

share|improve this answer
add comment

The standard output stream is mostly for console output. For instance, if in python, you do

print('hello world')

It will print to the Standard Output Stream (also called stdout).

To do what you want to do, you'd need to open the notepad with a location in the arguments, ask the user to save the file somehow, then read the file the user saved.

share|improve this answer
add comment

Your Answer


