Create TextReader Class : TextReader « File Directory « VB.Net






Create TextReader Class

 

Imports System
Imports System.IO

Public Class TextRW

    Shared Sub Main()
        Dim aStringWriter, aStreamWriter As TextWriter
        aStringWriter = New StringWriter()
        aStreamWriter = New StreamWriter("InvalidPathChars.txt")
        
        WriteText(aStringWriter)
        WriteText(aStreamWriter)
        aStreamWriter.Close()
        
        Dim aStringReader, aStreamReader As TextReader
        aStringReader = New StringReader(aStringWriter.ToString())
        aStreamReader = New StreamReader("InvalidPathChars.txt")
        
        ReadText(aStringReader)
        ReadText(aStreamReader)
        aStreamReader.Close()
    End Sub

    Shared Sub WriteText(aTextWriter As TextWriter)
        aTextWriter.Write("Invalid file path characters are: ")
        aTextWriter.Write(Path.InvalidPathChars)
        aTextWriter.Write("."C)
    End Sub

    Shared Sub ReadText(aTextReader As TextReader)
        Console.WriteLine("From {0} - {1}", _
            aTextReader.GetType().Name, aTextReader.ReadToEnd())
    End Sub

End Class

   
  








Related examples in the same category