Read and Write Files : Text File Read « File Directory « VB.Net

Read and Write Files

Public Class MainClass
    Public Shared Function ReadTextFromFile(ByVal Filename As String) As String
        Dim strFileText As String
        Dim MyReader As System.IO.StreamReader = System.IO.File.OpenText(Filename)
        strFileText = MyReader.ReadToEnd
        Return strFileText
    End Function

    Public Shared Sub WriteTextToFile(ByVal Filename As String, ByVal Text As String)
        Dim MyWriter As System.IO.StreamWriter = System.IO.File.CreateText(Filename)
    End Sub

    Public Shared Sub Main
        WriteTextToFile("c:\b.txt", ReadTextFromFile("c:\a.txt"))
    End Sub
End Class


Related examples in the same category

1.Read Text File ContentRead Text File Content
2.Open Text file and count the lines
3.Read Text File in a single StatementRead Text File in a single Statement
4.Text File content outputText File content output
5.Read Text from a File
6.Read lines from a text file
7.Open text file to read
8.Read Text from a File
9.Read line by line from a text file
10.Read Text from a File with DO Until