Console::OpenStandardError Method ()
.NET Framework (current version)
Acquires the standard error stream.
Assembly: mscorlib (in mscorlib.dll)
public: [HostProtectionAttribute(SecurityAction::LinkDemand, UI = true)] static Stream^ OpenStandardError()
This method can be used to reacquire the standard error stream after it has been changed by the SetError method.
The following example is a simple text file viewer that displays the contents of one or more text files to the console. If there are no command line arguments, or if any files passed as command line arguments do not exist, the example calls the SetError method to redirect error information to a file, calls the OpenStandardError method in the process of reacquiring the standard error stream, and indicates that error information was written to a file.
.NET Framework
Available since 1.1
Available since 1.1
Show:
Note that the StreamWriter::AutoFlush property is set to true before reacquiring the error stream. This ensures that output will be sent to the console immediately rather than buffered.