Mega Code Archive

 
Categories / VB.Net / Development
 

Console Error Property gets the standard error output stream

Imports System.IO Public Class ExpandTabs     Private Const tabSize As Integer = 4     Public Shared Function Main(ByVal args() As String) As Integer         Dim writer As StreamWriter = Nothing         Dim standardOutput As TextWriter = Console.Out         Try             writer = New StreamWriter("c:\\a.txt")             Console.SetOut(writer)             Console.SetIn(New StreamReader("c:\\a.txt"))         Catch e As IOException             Dim errorWriter As TextWriter = Console.Error             errorWriter.WriteLine(e.Message)             Return 1         End Try         Dim i As Integer         i = Console.Read()         While i <> -1             i = Console.Read()         End While         writer.Close()         Console.SetOut(standardOutput)         Return 0     End Function End Class