loading in file names

I want to take the names of a bunch of files and load them into listbox control in VC++.

Here is an example

test1.emf
test2.emf

I want the test1 and test2 part of the file name to show up in the listbox control.  If I add more files then those name will be loaded into the listbox without having to recompile the program.
LVL 2
simongodAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

captainkirkCommented:
1) You can use FindFirstFile() to find the first file with a given extension and then use FindNextFile() in a loop to get the rest.

2) in the loop, trim off the extension part of the filename and do a CListBox::AddString() to place the trimmed filename in the list box...

hope that helps...
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
simongodAuthor Commented:
can you actually write the code for me or be more specific?  What you tell me will work but I need specifics.  I don't really have time for "brainstorming", I just want some code.  If you write the code then I will up the pts by 50.
0
captainkirkCommented:
I should ask a couple of questions:

1) What is to be the source of the filenames??

2) if the source of the filenames is a directory search (if you want to search a particular directory subtree), then do you want an entry edit box to specify that start directory??

0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

simongodAuthor Commented:
the program is dialog based, when it starts the program searches through the subdirectories located only in the same path as the program.  It only searches for EMF type files.  then it should take the name of the file and load it into a listbox or combobox control.

example -

directory = new
program name = new.exe
subdir = block

this is the actual directory that I want searched.  It contains a few more dir's, but each one contains emf files.  Any emf file that is added to the block dir will be displayed in the listbox or combo box (preferably listbox)  I don't want the emf part of the file name to be displayed just the first part of the name.

test1.emf
test2.emf
test3.emf

only test1, test2, test3 will be shown not the emf part of the file.  IU would like it to be in decending order.  No left to right and decending stuff, just decending.

0
captainkirkCommented:
1) The comment has your list in ascending order - you would like to see it like:

test4
test3
test2
test1

2) do you want to dynamically specify the starting directory (like in a file selection dialog)?
0
simongodAuthor Commented:
no the search should only be in subdir of where the program resides.
0
simongodAuthor Commented:
i am using winnt does that make a difference?
0
captainkirkCommented:
thanks...
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.