How can I get the name of folders in a specific folder and the number of folders in that specific folder?
and then cycle through them?
Printable View
How can I get the name of folders in a specific folder and the number of folders in that specific folder?
and then cycle through them?
There's an FAQ to that effect: http://faq.cprogramming.com/cgi-bin/...&id=1044780608
Yeah but I don't know the name of the folder and that faq requires one to search for =\
Sorry, I misread your question. (Or maybe it was edited.)
You coould use the directory walker to find the names of the files and directories. Then you could try chdir()ing to each one to see if it's a directory. Or you could use stat/fstat to see if it is a directory. (chdir() and fstat() are part of the POSIX standard.) [edit] stat might be best: http://www.gnu.org/software/libc/man...ttributes.html [/edit] [edit=2] Here's a better link: http://www.scit.wlv.ac.uk/~jphb/spos...alls/stat.html [/edit]
[edit=3] I wrote a (convulted) program a long time ago that does this, you can see it if you like: http://dwks.theprogrammingsite.com/myprogs/df.htm [/edit] [edit=4] Never mind, it doesn't use stat. Okay, I'll stop editing now. :) [/edit]
Try putting in a * for the folder/file name. If there's a function to find names by giving a name
It was edited to add "and cycle through them"Quote:
Originally Posted by dwks
EDIT:and is there any other simpler way in C++ to find directory contents?
Well then I guess I just misread it. :)
Uh . . . twomers, that's not going to help.Quote:
Originally Posted by twomers
[edit] You edited it. Oh well. Look what I did. :) [/edit]
Why not? I remember using a file/folder thing from andrewxw's site and I threw in a * and it listed everything in the directory
Something from here http://www.adrianxw.dk/SoftwareSite/index.html
Not really.Quote:
EDIT:and is there any other simpler way in C++ to find directory contents?
argh this is my code
How hard do you think it is going to be to incorporate that in to my code?Code:Look in new post
Oh, you're using the Win32 version. Okay. Then you'd want the win32 stat, whatever that is. I don't know what it's called.
To be more speific
http://www.adrianxw.dk/SoftwareSite/...irstFile1.html
http://www.adrianxw.dk/SoftwareSite/...irstFile2.html
http://www.adrianxw.dk/SoftwareSite/...irstFile3.html
is all about logging directories
If you look carefully, the FAQ detects subdirectories.
I believe boost::filesystem can handle this.
>> I believe boost::filesystem can handle this.
I think you know it can! I have to investigate this boost jazz.