This documentation is archived and is not being maintained.
Console::Error Property
Visual Studio 2010
Gets the standard error output stream.
Assembly: mscorlib (in mscorlib.dll)
Property Value
Type: System.IO::TextWriterA TextWriter that represents the standard error output stream.
This property is set to the standard error stream by default. This property can be set to another stream with the SetError method.
The following code example illustrates the use of the Error property.
int main() { const int tabSize = 4; array<String^>^args = Environment::GetCommandLineArgs(); String^ usageText = "Usage: EXPANDTABSEX inputfile.txt outputfile.txt"; StreamWriter^ writer = nullptr; TextWriter^ standardOutput = Console::Out; if ( args->Length < 3 ) { Console::WriteLine( usageText ); return 1; } try { writer = gcnew StreamWriter( args[ 2 ] ); Console::SetOut( writer ); Console::SetIn( gcnew StreamReader( args[ 1 ] ) ); } catch ( IOException^ e ) { TextWriter^ errorWriter = Console::Error; errorWriter->WriteLine( e->Message ); errorWriter->WriteLine( usageText ); return 1; } int i; while ( (i = Console::Read()) != -1 ) { Char c = (Char)i; if ( c == '\t' ) Console::Write( ((String^)"")->PadRight( tabSize, ' ' ) ); else Console::Write( c ); } writer->Close(); // Recover the standard output stream so that a // completion message can be displayed. Console::SetOut( standardOutput ); Console::WriteLine( "EXPANDTABSEX has completed the processing of {0}.", args[ 0 ] ); return 0; }
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Show: