Home

Read Text From/Write Text To a File

Posted by SteveHardie | On: Nov 13 2009

This is a quick and easy way to read a files content into a string, or write a string to a file.

Read File Contents:

Dim strContent As String
Using fs As New IO.StreamReader(fileName)
    strContent = fs.ReadToEnd
End Using

Write content to file:

Dim strContent As String = "Content"
Using fs As New IO.StreamWriter(fileName)
    strContent = fs.Write(strcontent)
End Using

Leave a comment