[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

loading in file names

Posted on 1999-12-07
8
Medium Priority
?
193 Views
Last Modified: 2010-04-01
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.
0
Comment
Question by:simongod
  • 4
  • 4
8 Comments
 
LVL 4

Accepted Solution

by:
captainkirk earned 200 total points
ID: 2262358
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
 
LVL 2

Author Comment

by:simongod
ID: 2262419
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
 
LVL 4

Expert Comment

by:captainkirk
ID: 2262690
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
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
LVL 2

Author Comment

by:simongod
ID: 2262727
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
 
LVL 4

Expert Comment

by:captainkirk
ID: 2262755
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
 
LVL 2

Author Comment

by:simongod
ID: 2262856
no the search should only be in subdir of where the program resides.
0
 
LVL 2

Author Comment

by:simongod
ID: 2262959
i am using winnt does that make a difference?
0
 
LVL 4

Expert Comment

by:captainkirk
ID: 2263366
thanks...
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

612 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question