Check if folder exist?

  • Thread starter Thread starter Vsn
  • Start date Start date
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
 
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
 

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