I want to be able to put all the file names of a specific extension into a string array so i can load them into my program.
How dose that work?
Printable View
I want to be able to put all the file names of a specific extension into a string array so i can load them into my program.
How dose that work?
have to use a file search of some sort...then maybe build a data base...
If you're doing this in WIN32API look up the functions FindFirstFile
and FindNextFile in the Help or in a book.
> I want to be able to put all the file names of a specific extension into a string array
Well the way you find filenames is by using
For DOS/Windows
findfirst and findnext
You'll need to look up the exact names, there are several variants, depending on which specific MS OS you have
For Unix/Linux
opendir, readdir, closedir are the functions you want
I looked it up on MSDN, and im still not quite getting it.
I tried something like this, but it just crashes the program when it runs.
WIN32_FIND_DATA * data;
FindFirstFile("*.txt",data);
filename = data->cFileName;
if filename is a char* you will need to use strcpy() instead of = .
secondly salem has posted an excellent directory walker at least twice.A search will throw that up.You will learn much from that small piece of code.
> WIN32_FIND_DATA * data;
> FindFirstFile("*.txt",data);
That's because you should have written...
WIN32_FIND_DATA data;
FindFirstFile("*.txt", &data);
When something takes a * parameter, it's not good enough to simply declare a variable of that type, you've got to make sure it points somewhere.
Or, you declare a variable without the *, and you pass &var to the function instead.
> secondly salem has posted an excellent directory walker at least twice.
*blush* :)