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?
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?
Last edited by bikr692002; 09-04-2006 at 01:56 PM.
There's an FAQ to that effect: http://faq.cprogramming.com/cgi-bin/...&id=1044780608
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.
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]
Last edited by dwks; 09-04-2006 at 02:08 PM.
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.
Try putting in a * for the folder/file name. If there's a function to find names by giving a name
Last edited by twomers; 09-04-2006 at 02:09 PM.
It was edited to add "and cycle through them"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.Originally Posted by twomers
[edit] You edited it. Oh well. Look what I did. [/edit]
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.
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
Last edited by twomers; 09-04-2006 at 02:12 PM.
Not really.EDIT:and is there any other simpler way in C++ to find directory contents?
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.
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
Last edited by bikr692002; 09-04-2006 at 02:27 PM.
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.
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.
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.
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.
I believe boost::filesystem can handle this.
You ever try a pink golf ball, Wally? Why, the wind shear on a pink ball alone can take the head clean off a 90 pound midget at 300 yards.
>> I believe boost::filesystem can handle this.
I think you know it can! I have to investigate this boost jazz.