Process.StandardInput Property

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Gets a stream used to write the input of the application.

Namespace:   System.Diagnostics
Assembly:  System (in System.dll)

[<BrowsableAttribute(false)>]
member StandardInput : StreamWriter with get

Property Value

Type: System.IO.StreamWriter

A StreamWriter that can be used to write the standard input stream of the application.

Exception Condition
InvalidOperationException

The StandardInput stream has not been defined because ProcessStartInfo.RedirectStandardInput is set to false.

A Process can read input text from its standard input stream, typically the keyboard. By redirecting the StandardInput stream, you can programmatically specify the input. For example, instead of using keyboard input, you can provide text from the contents of a designated file or output from another application.

System_CAPS_noteNote

To use StandardInput, you must set ProcessStartInfo.UseShellExecute to false, and you must set ProcessStartInfo.RedirectStandardInput to true. Otherwise, writing to the StandardInput stream throws an exception.

The following example illustrates how to redirect the StandardInput stream of a process. The example starts the sort command with redirected input. It then prompts the user for text, and passes that to the sort process by means of the redirected StandardInput stream. The sort results are displayed to the user on the console.

No code example is currently available or this language may not be supported.

LinkDemand

for full trust for the immediate caller. This member cannot be used by partially trusted code.

.NET Framework
Available since 1.1
Return to top
Show: