Programming Tutorials

The text writer in VB.net

By: Issac in VB.net Tutorials on 2009-01-31  

TextWriter is similar to TextReader we can write a given content in a file at one strench in to a file using it. 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("www.java-samples.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 www.java-samples.com






Add Comment

* Required information
1000

Comments

No comments yet. Be the first!

Most Viewed Articles (in VB.net )

Latest Articles (in VB.net)