Using the File System: Writing to and Reading from Files
Many programs interact with external data, such as a database, XML, or even a text file. In a previous lesson, you learned how to create a database and use the data in your program. You can also use data that is stored in files and folders on your computer. Visual Basic makes it easy to read from and write to files by using the My.Computer.FileSystem Object.
In this set of lessons, you will create a Picture Viewer application with which you can view pictures in your MyPictures folder. You will learn how to use the My object to read file names from the folder and to read from and write to a text file.
In This Section
Retrieving the Names of Files in a Folder
Explains how to retrieve the names of files in a folder by using the My.Computer.FileSystem Object.Writing to a Text File
Explains how to write a string to a text file by using the My.Computer.FileSystem Object.Reading from a Text File
Explains how to read a comma-delimited text file and add each item in the file to a list.Deleting a Text File
Explains how to delete a text file from a folder.
Related Sections
Closer Look: Parsing File Paths
Explains how to parse a file path to separate the name of the file from its path.Visual Basic Guided Tour
The Visual Basic Guided Tour is a series of sequential lessons that will introduce you to the basics of programming in Visual Basic.