Array of Files in a Directory

This is a discussion on Array of Files in a Directory within the C++ Programming forums, part of the General Programming Boards category; Just a quick question: How do I get an array or something like that of all the files in a ...

  1. #1
    Registered User JasonLikesJava's Avatar
    Join Date
    Mar 2002
    Posts
    175

    Question Array of Files in a Directory

    Just a quick question:

    How do I get an array or something like that of all the files in a directory.

    Thanks in advance!

  2. #2
    S­énior Member
    Join Date
    Jan 2002
    Posts
    982
    It depends on what operating system and compiler you are using.

  3. #3
    Registered User JasonLikesJava's Avatar
    Join Date
    Mar 2002
    Posts
    175
    Sorry about that...

    I've got Windows and I use MingW and Cygwin, but mostly MingW.

  4. #4
    Registered User JasonLikesJava's Avatar
    Join Date
    Mar 2002
    Posts
    175
    Is this actually a difficult question?

  5. #5
    S­énior Member
    Join Date
    Jan 2002
    Posts
    982
    You need to fill a WIN32_FIND_DATA struct with a call to FindFirstFile() and then iterate through the directory with FindNextFile() until it returns INVALID_HANDLE_VALUE. Each time FindNextFile() returns sucessfully the filename will be a member of the WIN32_FIND_DATA struct which you could use to fill an array. You'll need to include windows.h; search the boards/MSDN for an example if needed.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to extract a list of files in a specific directory?
    By Perspektyva in forum C++ Programming
    Replies: 4
    Last Post: 11-11-2008, 01:02 PM
  2. Copying all files in a directory
    By rak1986 in forum C Programming
    Replies: 2
    Last Post: 08-25-2008, 01:02 AM
  3. deleting all files in a directory using c..
    By ShadeS_07 in forum C Programming
    Replies: 6
    Last Post: 07-30-2008, 08:21 AM
  4. Moving files from one directory to multiple dirs
    By csj561 in forum C Programming
    Replies: 7
    Last Post: 03-18-2005, 02:52 PM
  5. searching files in directory
    By lobo in forum Windows Programming
    Replies: 5
    Last Post: 10-05-2001, 03:00 AM

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