Home  |   French  |   About  |   Search  | mvps.org  

What's New
Table Of Contents
Credits
Netiquette
10 Commandments 
Bugs
Tables
Queries
Forms
Reports
Modules
APIs
Strings
Date/Time
General
Downloads
Resources
Search
Feedback
mvps.org

In Memoriam

Terms of Use


VB Petition

Modules: Check to see if a File or Directory exists

Author(s)
Dev Ashish

(Q)    Is there a simple way to check if a particular file or folder exist?

(A)    Yes,  the Dir function can be easily used for this.

(Thanks Andy Baron for the correction)

'***************** Code Start *******************
'This code was originally written by Dev Ashish
'It is not to be altered or distributed,
'except as part of an application.
'You are free to use it in any application,
'provided the copyright notice is left unchanged.
'
'Code Courtesy of
'Dev Ashish
'
Function fIsFileDIR(stPath As String, _
                    Optional lngType As Long) _
                    As Integer
'Fully qualify stPath
'To check for a file
'   ?fIsFileDIR("c:\winnt\win.ini")
'To check for a Dir
'   ?fIsFileDir("c:\msoffice",vbdirectory)
'
    On Error Resume Next
    fIsFileDIR = Len(Dir(stPath, lngType)) > 0
End Function
'***************** Code End *********************

© 1998-2010, Dev Ashish & Arvin Meyer, All rights reserved. Optimized for Microsoft Internet Explorer