Open a File in vb.net 2008
How to open a file in VB.NET?
Explanation
Opening a File in Vb.net 2008.
To
open a file, the File.OpenText method of the
FileStream class is used along with the
StreamReader class. Files are opened by default in synchronous mode, by using contructors files can also be opened
asynchronously.
Example:
Imports System.IO
Module Module1
Sub Main()
Dim r As StreamReader
r = File.OpenText("c:sample1.txt")
Console.WriteLine(r.ReadToEnd)
Console.Read()
r.Close()
End Sub
End Module
Result:
Welcome to.Net Programming
This is an example to open a File
In the above example, the
File.OpenText method and the
StreamReader class is used to open a text
file 'sample1.txt'.