
DirectCast Function | 249
The Language
Reference
This is the Title of the Book, eMatter Edition
Copyright © 2006 O’Reilly & Associates, Inc. All rights reserved.
• Using
Volume for attributes returns the volume label for the drive specified by
pathname instead of a matching filename.
• In previous versions of Visual Basic, the Dir function was commonly used to
determine whether a particular file existed. Although it can still be used for this
purpose, the System.IO.File.Exists method is more straightforward. In Visual
Basic 2005, the My.Computer.FileSystem.FileExists method also checks for the
existence of a file.
• The
Dir function returns filenames in the order in which they appear in the file-
allocation table.
• The
Dir function saves its state between invocations. This means that the func-
tion cannot be called recursively. For example, if the function returns the name of
the directory, you cannot then call the
Dir function to iterate the files in that
directory and then return to the original directory.
• If you are calling the
Dir function to return the names of one or more files, you
must provide an explicit file specification. For instance, if you want to retrieve the
names of all files in the Windows directory, the function call:
fileMatch = Dir("C:\windows", FileAttribute.Normal)
fails. Instead, the Dir function must be called with pathname defined as follows:
fileMatch = Dir("C:\windows\*.*", ...