This walkthrough provides an introduction to the fundamentals of file I/O in Visual Basic. It describes how to create a small application that lists and examines text files in a directory. For each selected text file, the application provides file attributes and the first line of content. There is an option to write information to a log file.
-->
This walkthrough uses members of the
My.Computer.FileSystem Object , which are available in Visual Basic. See FileSystem for more information. At the end of the walkthrough, an equivalent example is provided that uses classes from the System.IO namespace.
Note
Apr 27, 2005 Microsoft Visual Basic 6.0 Common Controls. Click the Download button on this page to start the download, or select a different language from the Change language drop-down list and click Go. To start the installation immediately, click Run. To save the download to your computer for installation at a later time, click Save.
Your computer might show different names or locations for some of the Visual Studio user interface elements in the following instructions. The Visual Studio edition that you have and the settings that you use determine these elements. For more information, see Personalizing the IDE.
To create the project
To select a folder, and list files in a folder
To obtain attributes of a file, and content from a text file
To add a log entry
To use the current directory
To selectively enable controls
Full example using My.Computer.FileSystem
Following is the complete example.
Full example using System.IO
The following equivalent example uses classes from the System.IO namespace instead of using
My.Computer.FileSystem objects.
See alsoComments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
December 2022
Categories |