Link to home
Start Free TrialLog in
Avatar of wtisystems
wtisystems

asked on

Finding the first entry in a directory with a vb.net control

My previous question was not worded correctly.

How do I find the first entry for a specific key in a directory using a vb.net control?
I think it's the "OpenFileDialog" control but I can't get it to work.
For example,
Directory Entries:
aafile1.txt
aafile2.txt
aafile3.txt
bbfile1.txt
bbfile2.txt
ccfile1.txt
ccfile2.txt
ccfile3.txt
I want to find bbfile1.txt.
I know the entires begin with "bb", but I don't know the exact names of the files.
Thank you.
ASKER CERTIFIED SOLUTION
Avatar of Rhino1272
Rhino1272
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of kaufmed
If for some reason you were wanting to use OpenFileDialog to present to your users, you could set the Filter property as in the top line of the snippet. (The vertical bar separates the friendly name from the search criteria.)

"Files" represents the friendly name the user would see in the file-type selection drop-down and "t*" represents the search pattern. For the search pattern, you could do something like "*.txt" to only show the text files in the working directory of the OpenFileDialog.

You can also specify multiple criteria using the bottom line in the sippet. (The semicolon separates the different file types.)
openFileDialog1.Filter = "Files|t*"
 
openFileDialog1.Filter = "Files|t*;More Files|*.txt"

Open in new window