How to VB.NET Simple TextReader
Textreader and TextWriter are the another way to read and write file respectively, even though these are not stream classes. The StreamReader and StreamWriter classes are derived from TextReader and TextWriter classes respectively. The following program using TextReader , Read the entire content of the file into a String
Imports System.IO Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles Button1.Click Try Dim line As String Dim readFile As System.IO.TextReader = New _ StreamReader("C:\Test1.txt") line = readFile.ReadToEnd() MsgBox(line) readFile.Close() readFile = Nothing Catch ex As IOException MsgBox(ex.ToString) End Try End Sub End Class
When you execute this program , TextReader read the entire file in one stretch.
Related Topics
- How to VB.NET Directory operations
- How to VB.NET File operations
- How to VB.NET FileStream
- How to VB.NET TextReader
- How to VB.NET TextWriter
- How to VB.NET BinaryReader
- How to VB.NET BinaryWriter
- How to convert xps file to bmp file
- How to VB.Net Path Class
- How to create PDF files in vb.net
- How to convert text file to pdf
- Write database to PDF file
Related Topics