AllAPI Network - The KPD-Team

 
Allapi Network
 API-Guide
 ApiViewer

 API List

 
API Resources
 Tips & Tricks
 VB Tutorials
 Error Lookup
 
Misc Stuff
 VB examples
 VB Tools
 VB Links
 Top Downloads
 
This Site
 Search Engine
 Contact Form
 

Donate to AllAPI.net

How can I find out if a file exists on a disk?

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

 

 


Copyright © 1998-2007, The Mentalis.org Team - Privacy statement
Did you find a bug on this page? Tell us!
This site is located at http://allapi.mentalis.org/