Verify folder exists

  • Thread starter Thread starter austin via AccessMonster.com
  • Start date Start date
A

austin via AccessMonster.com

I found two techniques on this forum to verify if a file or folder exists:

Len(Dir("c:\myfolder\", lngType)) is greater than zero

Dir$("c:\myfolder\") does not return a zero length string.

Neither of these techniques will detect an empty folder. Anyone know how to
verify the existence of a folder that may be empty?
 
austin via AccessMonster.com said:
I found two techniques on this forum to verify if a file or folder
exists:

Len(Dir("c:\myfolder\", lngType)) is greater than zero

Dir$("c:\myfolder\") does not return a zero length string.

Neither of these techniques will detect an empty folder. Anyone know
how to verify the existence of a folder that may be empty?

When you tried the first method, what value did you use for lngType?
This should work:

If Len(Dir("c:\myfolder", vbDirectory)) > 0 Then
' The folder exists.
End If

It should work with or without a trailing back-slash on the folder path:

If Len(Dir("c:\myfolder\", vbDirectory)) > 0 Then
' The folder exists.
End If
 

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

Back
Top