How can I find the path to a known file using VB

G

gama

I'd like to find the paths to different files that have the same name and
extension but are in different sub folders. I like to do this in VB. Any
suggestions welcome and greatly appreciated.
 
T

Tony Toews [MVP]

gama said:
I'd like to find the paths to different files that have the same name and
extension but are in different sub folders. I like to do this in VB. Any
suggestions welcome and greatly appreciated.

You'll have to start with the following code to search through all the
subfolders. Modify to suit such as adding file paths and names to an
array, etc, etc.

Minimal Code for a Recursive Search for Files (single drive)
http://vbnet.mvps.org/index.html?code/fileapi/recursivefolders_minimal.htm


Tony
--
Tony Toews, Microsoft Access MVP
Tony's Main MS Access pages - http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
For a free, convenient utility to keep your users FEs and other files
updated see http://www.autofeupdater.com/
Granite Fleet Manager http://www.granitefleet.com/
 
K

Karl E. Peterson

T

Tony Toews [MVP]

Karl E. Peterson said:
The API can be marginally faster, but for those who are more comfortable with
"native VB" here's the hand-rolled version: http://vb.mvps.org/samples/DirDrill

Good alternative. I'm exceedingly comfortable with API calls but some
might find them intimidating.

"No APIs were harmed in the making of this sample."

Hehehehe Good one!

Tony
--
Tony Toews, Microsoft Access MVP
Tony's Main MS Access pages - http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
For a free, convenient utility to keep your users FEs and other files
updated see http://www.autofeupdater.com/
Granite Fleet Manager http://www.granitefleet.com/
 
K

Karl E. Peterson

Tony said:
Good alternative. I'm exceedingly comfortable with API calls but some
might find them intimidating.

I did it mainly as an exercise to counter those who argue that Dir() can't be used
recursively. It certainly can. But to do so safely, I'm afraid, you almost need an
understanding of the underlying API and the ugly way that VB deals with Find
handles.
"No APIs were harmed in the making of this sample."

Hehehehe Good one!

:)
 

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