Amount of Files in a Directory

This is a discussion on Amount of Files in a Directory within the C++ Programming forums, part of the General Programming Boards category; Is there a way to find out the amount of files in a directory? If so how would I do ...

  1. #1
    Spanky devour89's Avatar
    Join Date
    Nov 2002
    Posts
    148

    Amount of Files in a Directory

    Is there a way to find out the amount of files in a directory?

    If so how would I do this?

    -Devouring One-
    Dev C++
    Win XP/2k/98

    I DO NOT TAKE CLASSES I DONT GET HOMEWORK THIS IS NOT A HOMEWORK QUESTION!!!

    He's lean he's keen... He's the spank machine!

  2. #2
    Registered User
    Join Date
    Nov 2001
    Posts
    1,348
    One solution is to use FindFirstFile() and FindNextFile() to access all files as you keep count.

    Kuphryn

  3. #3
    Spanky devour89's Avatar
    Join Date
    Nov 2002
    Posts
    148
    Yeah i figured I could do that.. but then what the actual goal is, is to keep on reading the files in the directory until the last one so I need to know how many files there are before hand....

    Thanx anyways

    -Devouring One-
    Dev C++
    Win XP/2k/98

    I DO NOT TAKE CLASSES I DONT GET HOMEWORK THIS IS NOT A HOMEWORK QUESTION!!!

    He's lean he's keen... He's the spank machine!

  4. #4
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,831
    >>> so I need to know how many files there are before hand..

    No. FindNextFile() returns TRUE if it successfully logged a file, when there are no more files left to log, it returns zero, and a call to GetLastError() will return the value ERROR_NO_MORE_FILES.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  5. #5
    Spanky devour89's Avatar
    Join Date
    Nov 2002
    Posts
    148
    So you are saying I could just have it loop for infinity and wait until it reaches the end?

    That solves the problem I guess

    Thanx

    -Devouring One-
    Dev C++
    Win XP/2k/98

    I DO NOT TAKE CLASSES I DONT GET HOMEWORK THIS IS NOT A HOMEWORK QUESTION!!!

    He's lean he's keen... He's the spank machine!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Reading .dat files from a folder in current directory...
    By porsche911nfs in forum C++ Programming
    Replies: 7
    Last Post: 04-04-2009, 09:52 PM
  2. How can i check a directory for certain files?
    By patrioticpar883 in forum C++ Programming
    Replies: 13
    Last Post: 02-01-2008, 04:27 PM
  3. Finding files in a directory
    By smarta_982002 in forum C Programming
    Replies: 1
    Last Post: 01-25-2008, 09:10 AM
  4. Opening all files in a directory
    By TKMan in forum C Programming
    Replies: 2
    Last Post: 11-11-2005, 12:27 PM
  5. Having a problem!
    By Zildjian in forum C++ Programming
    Replies: 6
    Last Post: 10-18-2004, 09:40 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21