This documentation is archived and is not being maintained.

Console.SetError Method

Sets the Error property to the specified TextWriter.

[Visual Basic]
Public Shared Sub SetError( _
   ByVal newError As TextWriter _
public static void SetError(
 TextWriter newError
public: static void SetError(
 TextWriter* newError
public static function SetError(
   newError : TextWriter


A TextWriter stream that is the new standard error output.


Exception Type Condition
ArgumentNullException newError is a null reference (Nothing in Visual Basic).
SecurityException The caller does not have the required permission.


By default, the Error property is set to the standard error output stream.

A StreamWriter that encapsulates a FileStream can be used to send error messages to a file.


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Common Language Infrastructure (CLI) Standard

.NET Framework Security: 

See Also

Console Class | Console Members | System Namespace | TextWriter | Error