Need function to determine whether a directory exists

B

Bob Valentine

Group:

I need help with the code to determine whether a directory (folder) exists.
I would like to pass a path to the function and have the function determine
whether all of the folders exist. For example, if I passed "C:\Documents and
Settings\owner\my documents\Backup Files\" to the function, I would like the
function to tell me whether this is a legitimate path.

Thanks,
BobV
 
D

Douglas J. Steele

Function FolderExists(FolderPath) As Boolean
FolderExists = (Len(Dir(FolderPath, vbDirectory)) > 0)
End Function

However, if you're already using the Dir function in your code, you'd be
better off using what Randy Birch has at
http://vbnet.mvps.org/code/fileapi/foldercontent.htm (Obligatory warning:
Randy's site is aimed at VB programmers. Because there are significant
differences between the controls available for forms in VB and in Access,
some of his code won't port directly to Access. Looking at this particular
example, though, you shouldn't have any issues)
 
B

Bob Valentine

Doug:

Thanks so much!

BobV

Douglas J. Steele said:
Function FolderExists(FolderPath) As Boolean
FolderExists = (Len(Dir(FolderPath, vbDirectory)) > 0)
End Function

However, if you're already using the Dir function in your code, you'd be
better off using what Randy Birch has at
http://vbnet.mvps.org/code/fileapi/foldercontent.htm (Obligatory warning:
Randy's site is aimed at VB programmers. Because there are significant
differences between the controls available for forms in VB and in Access,
some of his code won't port directly to Access. Looking at this particular
example, though, you shouldn't have any issues)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top