How do I use straight C++ code to find out how many files in a specific directory?
Thanks,
Grace ;)
Printable View
How do I use straight C++ code to find out how many files in a specific directory?
Thanks,
Grace ;)
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
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
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.
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?
This isn't a windows forum. There is a CodeGuru forum available that will address your question. You'll get better help there.
Jeff
Take a look hereQuote:
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?
Seems like there is no way. Thanks all!
*^____^*