Reading and Writing to Files
Module MainModule
Public Function ReadTextFromFile(ByVal Filename As String) As String
On Error Resume Next
Dim strFileText As String
Dim MyReader As System.IO.StreamReader = System.IO.File.OpenText(Filename)
strFileText = MyReader.ReadToEnd
MyReader.Close()
Return strFileText
End Function
Public Sub WriteTextToFile(ByVal Filename As String, ByVal Text As String)
Dim MyWriter As System.IO.StreamWriter = System.IO.File.CreateText(Filename)
MyWriter.Write(Text)
MyWriter.Close()
End Sub
End Module
Related examples in the same category