Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Obtaining list of files within a directory

Status
Not open for further replies.

NormRumac

Programmer
Sep 4, 2003
41
CA
Hi.

I was wondering how to obtain a list of all files from a given directory, provided they match certain wildcard criterea.

Is there an API function that will return me an array populated with the list of matching files?

If not, how can I accomplish this? Basically, I want to obtain a list of *.txt files in a certain directory, and then paste that list onto a combo box from which the user can select from.

Thanks,
--Norm
 

FindFirstFile and FindNextFile are the API's you are looking for. There are several examples around the web and this site. Even one at MS.

Have you read FAQ222-2244 yet?

Good Luck

 
Yes this seems to be what I am looking for.

Thanks.

--Norm
 
The most elegant and simplest solution is the [tt]CB_DIR[/tt] message, which does this job perfectly with a single [tt]SendMessage[/tt] call.
___
[tt]
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Const CB_DIR = &H145

Private Sub Form_Load()
SendMessage Combo1.hwnd, CB_DIR, vbNormal, ByVal "C:\Windows\*.txt"
End Sub
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top