Advertisement

File Listing

Started by December 18, 2000 12:51 PM
2 comments, last by Shannon Barber 24 years, 1 month ago
Anyone wanna explain or give a link? Just trying to build up a list of files inside of a directory. For example, the listing of files in explorer or in a single folder in windows. I''m going to need to load each file inside of a directory but I don''t want to make the user edit a text file telling what files are in it.
This can be broken done into distinct areas:
* if you want to just get the ''true'' files, the DOS true files (doesn''t matter about long file names), use something like this: (may need to change some names to get it to work with MSVC++ - look up findfirst, findnext):
  // Direct is the directory, Wildcard is the wildcard ex:// c:\\windows, *.*// c:\\game *.sav    ffblk ffblk;    int done;    char Buffer[80];    if(strcmp(Direct,"")==0) sprintf(Buffer,"%s",Wildcard);    else sprintf(Buffer,"%s\\%s",Direct,Wildcard);    done = findfirst(Buffer,&ffblk,0);    while (!done) {        char dirname[80];        if(strcmp(Direct,"")==0) sprintf(dirname,"%s",ffblk.ff_name);        else sprintf(dirname,"%s\\%s",Direct,ffblk.ff_name);// file name (and directory) in dirname; do your work here!        done = findnext(&ffblk);    }  

* if you want to read shortcuts, and other clever windows stuff you will need much more complex stuff which I don''t know about! Look it up on the net !


------------------------------
BCB DX Library - RAD C++ Game development for BCB
Advertisement
check out _findfirst() and _findnext() on the MSDN. I don''t know for linux though...

If you need more explanation, e-mail me, I can send you some example code, don''t have the time right now...
cya,
Phil

Visit Rarebyte!
and no!, there are NO kangaroos in Austria (I got this questions a few times over in the states
Visit Rarebyte! and no!, there are NO kangaroos in Austria (I got this question a few times over in the states ;) )
The MFC CEdit control has a Dir method that does that for you, if you willing to take that route... if nothing else you could track down the code for it.

I think there''s one for the tree control as well, if you want an explorer like interface.

There''s also a canned file open dialog thats part of the user interface shell.
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara

This topic is closed to new replies.

Advertisement