Listing file in directories

This is a discussion on Listing file in directories within the C Programming forums, part of the General Programming Boards category; Hey there, I haev been looking everywhere and I am unable to find a solution. I was wondering if it ...

  1. #1
    Longie
    Guest

    Question Listing file in directories

    Hey there, I haev been looking everywhere and I am unable to find a solution. I was wondering if it was at all possible to list files in a directory without having to make a loop of some sort and having to strcat() a string of some sort and checking if the file exists using fopen. If anyoen could help me li9st files in a directory it would eb MUCH appreciated, thanks.

    Daniel Wallace (Longie@magikweb.net)

  2. #2
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    Check out FindFirst() and FindNext() (It might be FindFirstFile and FindNextFile, can't remember...)
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  3. #3
    Me want cookie! Monster's Avatar
    Join Date
    Dec 2001
    Posts
    680
    It's FindFirstFile and FindNextFile (for win32)

  4. #4
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    >>. I was wondering if it was at all possible to list files in a directory
    This is OS dependant. You didn't state which OS/compiler you are using, nor I expect, did you do a board search before posting your question. Try hunting down the answer first, it has been asked before.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  5. #5
    TheWJM
    Guest

    Red face

    I take it your using Debian/gcc and not windows?

  6. #6
    Longie
    Guest
    Haha, sorry about that.

    Yes TheWJM :P I am using Debian Potato, latest release and the latest gcc. I know I can use the system() command and perform "ls", but that is slow and doesn't return the listing into the program.

    Well, that's the additional information I forgot to include last time. Thanks.

    Daniel Wallace (Longie@magikweb.net)

  7. #7
    Registered User
    Join Date
    Sep 2002
    Posts
    52

    Smile

    Thank you for that, it is exactly what I wanted :)

    Your help is much appreciated :) I look forward to reading this forum and helping out wherever I can.
    - Daniel Wallace

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 07:39 AM
  2. Batch file programming
    By year2038bug in forum Tech Board
    Replies: 10
    Last Post: 09-05-2005, 04:30 PM
  3. file processing updating record error
    By uuser in forum C Programming
    Replies: 2
    Last Post: 04-27-2003, 01:13 AM
  4. System
    By drdroid in forum C++ Programming
    Replies: 3
    Last Post: 06-28-2002, 11:12 PM
  5. Need a suggestion on a school project..
    By Screwz Luse in forum C Programming
    Replies: 5
    Last Post: 11-27-2001, 02:58 AM

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