Reputation: 11
I have a directory and it contains a number of files,
Some filenames start with say, abc_001.ini, abc_002.ini, abc_003.ini
and so on.
There are other files as well in the same folder.
I want to get a list of files which start with abc_ and have a ".ini" extension.
How can I do this in VB 6?
Upvotes: 1
Views: 5011
Reputation: 3381
Shamelessly stolen from the documentation at https://msdn.microsoft.com/en-us/library/aa262727(v=vs.60).aspx
MyPath = "c:\wherever\abc_*.ini" ' Set the path.
MyName = Dir(MyPath, vbDirectory) ' Retrieve the first entry.
Do While MyName <> "" ' Start the loop.
' Ignore the current directory and the encompassing directory.
If MyName <> "." And MyName <> ".." Then
Debug.Print MyName
End If
MyName = Dir ' Get next entry.
Loop
Upvotes: 2