This documentation is archived and is not being maintained.

FileSystem.OpenTextFileReader Method (String)

Opens a StreamReader.

Namespace: Microsoft.VisualBasic.FileIO
Assembly: Microsoft.VisualBasic (in microsoft.visualbasic.dll)

public static StreamReader OpenTextFileReader (
	string file
public static StreamReader OpenTextFileReader (
	String file
public static function OpenTextFileReader (
	file : String
) : StreamReader
Not applicable.



String. File to be read. Required.

Return Value


For more detailed information, see the Visual Basic topic My.Computer.FileSystem.OpenTextFileReader Method.

Only text files can be read with a StreamReader.

The following table lists examples of tasks involving the My.Computer.FileSystem.OpenTextFileReader method.

This example opens the file Testfile.txt, reads a line from it, and displays the line in a MessageBox.

Dim fileReader As System.IO.StreamReader
fileReader = _
Dim stringReader As String
stringReader = fileReader.ReadLine()
MsgBox("The first line of the file is " & stringReader)

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0