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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using FSO to get a folder name from a wildcard

Status
Not open for further replies.

AndyGroom

Programmer
May 23, 2001
972
0
0
GB
Imagine a series of folders with names such as:
Kirk [1]
Scotty [2]
Sulu [3]
Uhura [4]

I need some code such that I can pass the number (3) and it returns Sulu [3]. At the moment I'm doing it like this:
Code:
FolderName = Dir$(InFolder & "\*[" & Ref & "]", vbDirectory)
where ref is 3 and InFolder is the path containing the series of folders.

Would it be faster to do this using the FSO and if so what would the syntax be? Can it be done in one line?

- Andy
___________________________________________________________________
If you think nobody cares you're alive, try missing a couple of mortgage payments
 
There is no wildcard support in the FSO, you'd need to iterate a Folder object's Files collection to pick out the one you want.

Why is Dir$() a problem for you anyway?

All of this looks a bit suspicious, as if you are trying as hard as you can to avoid using a database for things a database is good at.
 
All of this looks a bit suspicious
Ha ha no, for my job I have to write utilities for other companies and this week's problem is dealing with a folder structure they've been using for six years or so and they now want to gather it all up into a CSV file at the end of each day. It's all inter-linked and I was just after a quick way to navigate to a particular folder without knowing the full name.

I already tried using the folder object but it's a lot slower than using Dir$(). There's nothing wrong with the way I'm doing it, it works just fine, I'm just always on the lookout for a better way.

- Andy
___________________________________________________________________
If you think nobody cares you're alive, try missing a couple of mortgage payments
 
Oh ok. No, Dir$() is pretty close to the API calls to accomplish the same thing.

I just thought those were really strange looking folder names, as if they encoded a key and name into one string instead of using a lookup table.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top