Nested File Search With Wildcards using File System Object


Version Compatibility: Visual Basic 6

More information:
The attached code shows how to locate files in a directory using the FileSystemObject. You can search just within the specified directory or include all subdirectories in the search.

Even though the FileSystemObject doesn't allow for wildcard symbols, I included code that shows how to use the wildcard symbol to help in locating a group of files. This allows you to do nested file searches with wildcards without using the Dir function or the FindFirstFile/FindNextFile API calls, which many peopele find confusing.

"Test.bmp" will only return that file if found. "*.frm" will return all files that end in ".frm" and "Test*" will return all files that start with "Test". In addition, semi-colon separation of search strings is supported, so *.txt;*.exe will return all file with a .txt or .exe extension.

Also included is an exampe of using the SendMessage API function to add a horizontal scroll bar dynamically to a list box.

NOTE: The Microsoft Scripting Runtime must be referenced to access the FileSystemObject.

Instructions: Click the link below to download the code. Select 'Save' from the IE popup dialog. Once downloaded, open the .zip file from your local drive using WinZip or a comparable program to view the contents.