By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,558 Members | 1,373 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,558 IT Pros & Developers. It's quick & easy.

Selecting a file by its location rather than its name

P: 9
I have a listbox and would like to use it to select a file from a known location, but I want to select by position as its name may change (example: if someone selects the first option in listbox then the first file within the folder d:\workpack is selected).

Thanks
Jan 21 '08 #1
Share this Question
Share on Google+
5 Replies


daniel aristidou
100+
P: 491
I have a listbox and would like to use it to select a file from a known location, but I want to select by position as its name may change (example: if someone selects the first option in listbox then the first file within the folder d:\workpack is selected).

Thanks
Is the file the only file in the folder......ie location or is there a group of files in the known location
Jan 21 '08 #2

P: 9
There are about 8 files in the subfolder and there 'll always be the same number of options in the listbox
Jan 21 '08 #3

Expert 5K+
P: 8,434
I think you'll find that most if not all methods of finding the file will return them in alphabetical order by file name. So the idea of "position" may not be meaningful.

But if you're ok with that, then it's pretty simple. Just start picking through the files in the folder, and stop when you get to the 'nth' one.
Jan 22 '08 #4

P: 9
Yes but what code do i need to select the nth file?
Jan 22 '08 #5

Expert 5K+
P: 8,434
It might depend a bit on what version of VB you're using. But in any case, look up "FileSystemObject model" in the documentation. This will explain how to use FSO to go through the files in a folder.
Jan 22 '08 #6

Post your reply

Sign in to post your reply or Sign up for a free account.