Check if folder exist?

V

Vsn

Hi all,

Can someone give me a solution on how I will be able to check if a folder
exist (empty as well).

I have always used below method to check if files exist.

=====================================START

Function CheckFileExist(fName as String, fPath as String)
On Error GoTo Err_CheckFileExist

If Len(Dir$(fPath & "\" & fName)) < 1 Then
CheckFileExist=False
Else
CheckFileExist=True
End if

Exit_CheckFileExist:
Exit Function

Err_CheckFileExist:
Select Case Err

Case 0

Case Else
MsgBox Err.Description & vbCrLf & Err.Number, vbCritical
Resume Exit_CheckFileExist
End Select

End Function
=====================================END


It works for folders as well until the folder is empty. Can somone give me a
clue?

Thx, a lot.
Ludovic
 
N

Nikos Yannacopoulos

Ludovic,

Try this function:

Function Folder_Exists(strFolder As String) As Boolean
Dim strCurrentFolder As String
strCurrentFolder = CurrentProject.Path
Folder_Exists = False
On Error GoTo Not_Found
ChDir (strFolder)
On Error GoTo 0
Folder_Exists = True
ChDir (strCurrentFolder)
Not_Found:
End Function

HTH,
Nikos
 
Top