Appendix U

Filesystem Classes

A Visual Basic application can take three basic approaches to filesystem manipulation: Visual Basic methods, System.IO Framework classes, and the My.Computer.FileSystem namespace. This appendix summarizes the properties, methods, and events provided by these approaches. For more information on filesystem objects, see Chapter 30, “Filesystem Objects.”

VISUAL BASIC METHODS

The following table summarizes the Visual Basic methods for working with files. They let a program create, open, read, write, and learn about files.

METHOD PURPOSE
EOF Returns True if the file is at the end of file.
FileClose Closes an open file.
FileGet Reads data from a file opened in Random and Binary mode into a variable.
FileGetObject Reads data as an object from a file opened in Random and Binary mode into a variable.
FileOpen Opens a file for reading or writing. Parameters indicate the mode (Append, Binary, Input, Output, or Random), access type (Read, Write, or ReadWrite), and sharing (Shared, LockRead, LockWrite, or LockReadWrite).
FilePut Writes data from a variable into a file opened for Random or Binary access.
FilePutObject Writes an object from a variable into a file opened for Random or Binary access.
FreeFile Returns a file number that is not currently associated with any file in this application. You should use FreeFile to get file numbers rather than use arbitrary numbers such as 1.
Input Reads data written into a file by the Write method back ...

Get Visual Basic 2012 Programmer's Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.