Net-informations.com
SiteMap  | About    

How to VB.NET TextWriter

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 sample source showing how write in a file using TextWriter .




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 writeFile As System.IO.TextWriter = New _
            StreamWriter("c:\textwriter.txt")
            writeFile.WriteLine("vb.net-informations.com")
            writeFile.Flush()
            writeFile.Close()
            writeFile = Nothing
        Catch ex As IOException
            MsgBox(ex.ToString)
        End Try
    End Sub
End Class

When you execute this source code , you will get a file TextWriter.txt and inside it written vb.net-informations.com .





net-informations.com (C) 2017    Founded by raps mk
All Rights Reserved. All other trademarks are property of their respective owners.