
Common Language Runtime • Chapter 4 155
File I/O
Probably one of the most familiar tasks for Visual Basic developers is simple file
I/O. Reading and writing to a file is something we have all done a lot of for a
multitude of purposes. Under VB.NET, file I/O is encapsulated in the System.IO
namespace. Let’s take a look at a simple example of reading from a file with
VB.NET.To make the example clearer, we first look at the code in current
versions of Visual Basic, and then we compare it to how it might look under
.NET.This example simply opens a file for reading, reads in a single line, and dis-
plays it in a message box to the user:
Sub Main()
Dim sBuff As String ...