Enumerate Files from Starting Folder Using Extension - July 2006

Recently I had a need to search a starting folder and all subfolders for files with a specified extension. I did not find the solution using Google. So I figured out how to use recursion with the Scripting Library [scrrun.dll] to perform the search. I encapsulated it in a class module called: 'cFolderEnum'. That process is described below. It becomes the tip-of-the-month.

Demo Program

I wrote a VB6 demo program to illustrate the use of the class. The demo:

Enumerate Files in Start-In Folder and Subfolders Searching by Extension.

Start-In Folder - Start the search in this folder. Auto completion is available.

Browse - Use the Browse button to find a folder.

Extension - Search for files with this extension.

Find Them - Click this button to begin the search.

Sample Calling Code

Sample Code

The Demo Program Uses These Modules

Project Explorer

Module - Click for More Info Description Used in the Demo To
cFolderEnum.cls The subject of this tip.  
Browse for a folder Browse for a folder.
cCreateGUID.cls Create a GUID A GUID is used as the key for each listitem.
cFilenameParse.cls Parse a fully qualified file name. Add and remove path backspaces.
clsLVMaxCol.cls Set ListView Column Widths Set the column widths to the size of the largest column entry.
modLocationLocationLocation.bas Form Housekeeping Set form size and location.
Not needed in your application.
modReg.bas Read the registry. Used by Location, Location, Location
modConnectToWebSite.bas Connect to a web site Show this info when Help/Info is
selected from the demo.
modInfoAbout.bas DoInfo, DoAbout, DoTip Link to this page and provide helpful information.
modNotTooSmallBig.bas Make sure a variable is within limits. Used in the Form_Resize event to make sure control sizes don't go negative.

Download VB Code

Click here to download the VB 6 source code [37k].

Previous Tip   Tip Index   Next Tip


Updated 2008/09/04