To find out if a file exists on a
disk you can use the Visual Basic Dir()
function. It has the following syntax:
Dir[(pathname[, attributes])]
In this context, pathname would be
the name of the file that you are trying
to find. The Attributes can be one or
more of the following values (separated
by the OR operator)
Attribute
|
Description
|
vbNormal
|
Default
Attribute
|
vbReadOnly
|
Use
if file pathname is read-only
|
vbHidden
|
Use
if the file pathname is hidden
|
vbSystem
|
Use
if the file pathname is a system
file
|
vbArchive
|
Use
if the file pathname is an
Archive file
|
vbDirectory
|
Use
if pathname is a directory
|
Example:
If
Dir(myfilename, vbNormal or vbReadOnly or
vbHidden or vbSystem or vbArchive) =
"" then
Call Msgbox
("This file does not exist")
Else
Call msgbox
("This file does exist")
End If
|