We help IT Professionals succeed at work.

the fastest way to retrieve all directories on a drive?

polygon asked
Medium Priority
Last Modified: 2012-06-21
Whould you tell me the FASTEST way to retrieve all directories on a drive.Is there any API function or something else that can help me? I use recursively call of Dir$ function but it takes 20s for ~13000 files and ~900 folders. Please help! (I've VB5.0 Enterprise Edition)
Watch Question

The solution is to use FindFirstFile and FindNextFile API functions. They can also be used to find directories, not only files. It's a little bit long to describe here, but a beautiful example is on the following web page:


If for some reason this URL doesn;t work, go to:


and search for directory. The article is entitled: "Drive, Folder & File Property Page Demo"

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Dear wolfrag,
Your answer is excellent.Thanks.
If you know something else that can help me you may email me at:
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.