Checking Existence of Folder (1 Viewer)

winkmich

Registered User.
Local time
Today, 08:46
Joined
Jun 21, 2002
Messages
18
Hi there,

I include an application into a form which opens a folder which is connected to the actual ID.

The function below check whether a folder with the name already exists or not. In case not, then a new folder will be created.
Strangely, the creation of the new folder works perfectly, but if the folder already exists, a warning "Path/File access error" appears.

Do I have to include a "else"-command into the if .. then command??

Has anyone an idea, where the problem could be?

Thanks in advance.

Michael.


Dim stAppName As String
Dim strDirectoryPath As String

strDirectoryPath = "f:\Database\LettersDirectories\" + CStr([ContactsID])

If Dir(strDirectoryPath) = "" Then
MkDir strDirectoryPath
End If

stAppName = "explorer.exe " + strDirectoryPath
Call Shell(stAppName, 1)
 

Travis

Registered User.
Local time
Today, 00:46
Joined
Dec 17, 1999
Messages
1,332
Try this:

If Dir(strDirectoryPath, vbDirectory) = "" Then
MkDir strDirectoryPath
End If


This tells the Dir Command that you are looking for a Directory, Not a File.
 

winkmich

Registered User.
Local time
Today, 08:46
Joined
Jun 21, 2002
Messages
18
Thanks Travis, vbDirectory works.
 

Users who are viewing this thread

Top Bottom