C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
Then: The String data returned by the File.ReadAllText function is stored in the Dim value. We get a string from a file.
Finally: The String data is printed to the screen with the Console.WriteLine subroutine.
VB.NET program that reads in text file
Imports System.IO
Module Module1
Sub Main()
' Open file and store in String.
Dim value As String = File.ReadAllText("C:\file.txt")
' Write to screen.
Console.WriteLine(value)
End Sub
End Module
Output
File contents.
Note: You can read a specific article on StreamReader, and also check out more general file handing tips in the VB.NET language.
StreamReaderStreamReader ReadToEnd