Home and Learn: VB Net Course
There is a very useful object in VB.NET called System.IO (the IO stands for Input and Output). You can use this object to read and write to text files.
We're going to be having a closer look at objects (and what System is) in the next section. For now, let's just see how to open up a text file using the System.IO object.
First, here's an explanation of just what we mean by "text file".
The files on your computer all end in a three letter extension. Microsoft Word files will have a different three letter extension from Microsoft Excel files. The extension is used to identify one file type from another. That way, Excel won't try to open Word files, or vice versa. You can just write some code to strip the last three letters from the file name, and then check that these three letters are the ones you want. Rather like the code you wrote to strip the last three letters from an email address.
Text files have an extension that ends in .txt. The Windows operating system gives you a good, basic Text Editor in Notepad. The Notepad programme allows you to save files with the .txt extension. In other words, as Text Files. These Text Files can then be opened by a wide variety of programmes.
A simple text file like this is called a Sequential File, and that is what we will be opening here. So let's begin.
Buy the Book of this Course
Email us: enquiry at homeandlearn.co.uk