CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8
  1. #1
    Join Date
    Jun 1999
    Posts
    176

    number of files in a directory (folder)?

    How do I use straight C++ code to find out how many files in a specific directory?

    Thanks,
    Grace

  2. #2
    Join Date
    Mar 2002
    Location
    California
    Posts
    1,582
    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

  3. #3
    Join Date
    Apr 1999
    Posts
    27,449
    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

  4. #4
    Join Date
    Sep 2002
    Posts
    1,747

    also

    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.

  5. #5
    Join Date
    Jun 1999
    Posts
    176
    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?

  6. #6
    Join Date
    Mar 2002
    Location
    California
    Posts
    1,582
    This isn't a windows forum. There is a CodeGuru forum available that will address your question. You'll get better help there.

    Jeff

  7. #7
    Join Date
    May 2000
    Location
    KY, USA
    Posts
    18,652
    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

  8. #8
    Join Date
    Jun 1999
    Posts
    176
    Seems like there is no way. Thanks all!
    *^____^*

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured