Check for existing Directories/Folders

By | 2002-06-01

Check if that directory exists before running the risk of an error and/or data loss. One of the few that really works. No API, no function calls. Existence check and logic included. Incredibly simple.

Original Author: unknown

Side Effects

None known

Code

'By Jim Sivage
'
'ISO Global
'http://www.isoglobal.com
'
'
'Make f$ equal to folder you're testing.
'
f$ = "C:WINDOWS"
dirFolder = Dir(f$, vbDirectory)
If dirFolder <> "" Then
strmsg = MsgBox("This folder already exists.", vbCritical):goto optout
End If
'directory exists action here
optout:

Author: dwirch

Derek Wirch is a seasoned IT professional with an impressive career dating back to 1986. He brings a wealth of knowledge and hands-on experience that is invaluable to those embarking on their journey in the tech industry.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.