Problem solve Get help with specific problems with your technologies, process and projects.

Reading a file using the IO library

The IO Class Library provides the functionality for all the input/output of an app. This example demonstrates how to read from a file using FileStream & StreamReader classes.

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:

Imports System
Imports System.IO
Imports Microsoft.VisualBasic
  Class ReadFile
    Shared Sub Main()
      'Declare a file stream object
       Dim o As 
      'Declare a stream reader object
       Dim r As

      '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
   End Sub
  End Class

Dig Deeper on .NET Workflow

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.