Listing files with full path

S

simonc

Is there any function which acts like Dir but returns the full path of the
file and not just its filename? I want to find files of a type in several
directories, load the names in an array then go through them all and process
them. It would help if the file names in the array contained the path
information so that the part of the macro which does the processing can go
straight to the file without having to worry about which folder it's in.

Grateful for advice.
 
D

Dave Ramage

Don't you already know the directory/folder at the time you call Dir? So just
concatenate this with the file name returned, e.g.

Const SEARCH_FOLDER as String = "C:\MyFolder\"
Dim sFiles(100) as String, s as String
Dim l as Long

s=Dir(SEARCH_FOLDER & "*.*")
Do While s>""
sFiles(l) = SEARCH_FOLDER & s
l=l+1
s=Dir
Loop

....or am I missing something?

Cheers,
Dave
 
S

simonc

Thank you. So simple I didn't think of it...

Dave Ramage said:
Don't you already know the directory/folder at the time you call Dir? So just
concatenate this with the file name returned, e.g.

Const SEARCH_FOLDER as String = "C:\MyFolder\"
Dim sFiles(100) as String, s as String
Dim l as Long

s=Dir(SEARCH_FOLDER & "*.*")
Do While s>""
sFiles(l) = SEARCH_FOLDER & s
l=l+1
s=Dir
Loop

...or am I missing something?

Cheers,
Dave
 

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

Top