Click to See Complete Forum and Search --> : number of files in a directory (folder)?


Grace
October 17th, 2002, 05:39 PM
How do I use straight C++ code to find out how many files in a specific directory?

Thanks,
Grace ;)

jfaust
October 17th, 2002, 05:54 PM
There is no way to do this with ANSI C++.

You must use calls to the OS. This question will probably get more attention if you post it to the VC++ forum.

Jeff

Paul McKenzie
October 17th, 2002, 05:59 PM
There are no standard library functions to get directory information such as the number of files.

It all depends on the OS you're using. For 32-bit Windows, the FindFirstFile / FindNextFile functions are used. For UNIX, the opendir / readdir functions are used. For 16-bit DOS it is a variety, depending on the compiler you used. For other OSes, consult your OS programmer's manual.

Regards,

Paul McKenzie

galathaea
October 17th, 2002, 06:11 PM
There are the c run-time _findfirst and _findnext on Visual C++, again not ANSI. I think you won't find anything that is not OS specific because the ANSI standard doesn't want to assume a particular file organization system, but I would love to see a post to the contrary.

Grace
October 17th, 2002, 09:19 PM
Thanks for all the replies. I am writing the code for the Windows platform. Do I have to loop thru all the files using FindNext or FindNextFile? Is there a count which I can simply use?

jfaust
October 17th, 2002, 10:16 PM
This isn't a windows forum. There is a CodeGuru forum available that will address your question. You'll get better help there.

Jeff

Andreas Masur
October 18th, 2002, 12:47 AM
Originally posted by Grace
Thanks for all the replies. I am writing the code for the Windows platform. Do I have to loop thru all the files using FindNext or FindNextFile? Is there a count which I can simply use?
Take a look here (http://www.codeguru.com/forum/showthread.php?s=&threadid=210270)

Grace
October 18th, 2002, 06:19 PM
Seems like there is no way. Thanks all!
*^____^*