Reading All Files In a Directory

Saj

Active Member
Licensed User
How do I go about reading all the names of files in a given directory. I've had a look under Help -> Files, but I couldn't see anything abvious.
 

akgh2010

Member
Licensed User
Longtime User
I think you can use Dir statement like this:
Dir("") ' To iterate over all files in the current folder, specify an empty string.
or
If Dir(strPath, vbDirectory) <> "" Then ' To search if a directory is there or not
...
End If
where strPath is a string variable and it could be something like this:
Dim strPath As String
strPath = "e:\my Project\"
Also you can use it like this:
Dir(strPath) ' Display the files in the specified directory stored in strPath
I hope this helps you.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…