Please let other users know how useful this tip is by rating it below. And, submit your own .NET tip or code.
The IO classes in the IO Class Library provide the basic functionality for all input/output functionality of an application -- reading or writing a file, accessing a directory, checking file access permissions, etc. This example demonstrates how to read from a file using the FileStream and StreamReader classes:
By submitting your personal information, you agree that TechTarget and its partners may contact you regarding relevant content, products and special offers.
Imports System Imports System.IO Imports Microsoft.VisualBasic Class ReadFile Shared Sub Main() 'Declare a file stream object Dim o As FileStream 'Declare a stream reader object Dim r As StreamReader 'Open the file o = New FileStream("c:myfile.txt", FileMode.Open,FileAccess.Read, FileShare.Read) 'Read the output in a stream reader r = New StreamReader(o) 'Display the content of the file msgbox(r.ReadtoEnd) End Sub End Class