List all Directories

Category:
Files and Directories
Type:
Snippets
Difficulty:
Intermediate
Author:
Craig Duffy

Version Compatibility: Visual Basic 6, Visual Basic 5

More information:
Pass in the starting directory to get an array of all directories below starting point. Can be modified to return files etc.

With this code, you need to add a listbox and a command button to a form. If you prefer, it would be easy to modify the method to return the array -- either include it as a ByRef Parameter or (VB6 only) make it the return value of the function.

Instructions: Copy the declarations and code below and paste directly into your VB project.

Declarations:

Code: