How to determine if directory exists

  • Thread starter Thread starter TTD
  • Start date Start date
T

TTD

Hello,

I need to create a directory in code, but when de directory already exists,
I get err.number 75.

Since the creation already is in the part where a former error is sent, I
can't catch this error.

In VB there is this code
path = "C:\temp\"
If Directory.Exists(path) = False Then
' Create the directory.
Directory.CreateDirectory(path)
End If

Is there a way to determine if C:\temp already exists before I create one?

Thanks for your time.
 
TTD said:
Hello,

I need to create a directory in code, but when de directory already
exists, I get err.number 75.

Since the creation already is in the part where a former error is
sent, I can't catch this error.

In VB there is this code
path = "C:\temp\"
If Directory.Exists(path) = False Then
' Create the directory.
Directory.CreateDirectory(path)
End If

Is there a way to determine if C:\temp already exists before I create
one?

Thanks for your time.

If Dir("C:\temp", vbDirectory) = "" Then
'folder does not exist
Else
'folder does exist
End If
 
Back
Top