Thread: Amount of Files in a Directory

  1. #1

    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
    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,829
    >>> 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
    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, 05:27 PM
  3. Finding files in a directory
    By smarta_982002 in forum C Programming
    Replies: 1
    Last Post: 01-25-2008, 10:10 AM
  4. Opening all files in a directory
    By TKMan in forum C Programming
    Replies: 2
    Last Post: 11-11-2005, 01:27 PM
  5. Having a problem!
    By Zildjian in forum C++ Programming
    Replies: 6
    Last Post: 10-18-2004, 09:40 AM