Mega Code Archive

 
Categories / VB.Net / Development
 

Console SetOut Method sets the Out property to the specified TextWriter object

Imports System.IO Imports System.Reflection Module RedirectStdErr    Public Sub Main()         Dim fs As New FileStream("Test.txt", FileMode.Create)         ' First, save the standard output.         Dim tmp as TextWriter = Console.Out         Dim sw As New StreamWriter(fs)         Console.SetOut(sw)         Console.WriteLine("Hello file")         Console.SetOut(tmp)         Console.WriteLine("Hello World")         sw.Close()    End Sub End Module