reading the contents of a directory

This is a discussion on reading the contents of a directory within the C++ Programming forums, part of the General Programming Boards category; i was told you can read the contents of a directory much like you would the contents of a file....Is ...

  1. #1
    Unregistered
    Guest

    reading the contents of a directory

    i was told you can read the contents of a directory much like you would the contents of a file....Is this true, and if so, how do i do it?

  2. #2
    Something Clever ginoitalo's Avatar
    Join Date
    Dec 2001
    Posts
    187
    I doubt thats in the ANSI C, so what platform are you using ?

    Win/Linux ??

  3. #3
    Unregistered
    Guest
    I'm using windows 98 second edition and ms visual 6.0.

  4. #4
    Unregistered
    Guest
    i forgot to add i'm using c++.

  5. #5
    Registered User Dual-Catfish's Avatar
    Join Date
    Sep 2001
    Posts
    802
    Try looking up dir.h on MSDN

  6. #6
    Unregistered
    Guest
    thanks, msdn was a lot of help and i now understand how to search through a directory.

    I now need a good algorithm for searching for a file on a computer starting at the root directory and searching through all folders.
    Should i search the root folder first, then start searching the subfolders or should i go to the deepest subfolder and start searching there?

    any pseudo code would be a great help.

    Thanks.

  7. #7
    Something Clever ginoitalo's Avatar
    Join Date
    Dec 2001
    Posts
    187
    I'd try to take into account what your searching for,

    ex.

    if you looking for a file that has the letters 'win' in it,
    Try to begin your search in the windows folder.
    so, a substring search on all the folders in the root to begin...

  8. #8
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571
    Originally posted by Unregistered
    thanks, msdn was a lot of help and i now understand how to search through a directory.

    I now need a good algorithm for searching for a file on a computer starting at the root directory and searching through all folders.
    Should i search the root folder first, then start searching the subfolders or should i go to the deepest subfolder and start searching there?

    any pseudo code would be a great help.

    Thanks.
    I'm not sure why you would need to do this.

  9. #9
    Unregistered
    Guest
    well, i can search for the file in the current working directory just fine or if i specify a directory path. But say i don't know what directory the file is in? What's the best approach to traversing the directories for the file?

  10. #10
    Registered User
    Join Date
    Apr 2002
    Posts
    2
    Originally posted by Unregistered
    thanks, msdn was a lot of help and i now understand how to search through a directory.

    I now need a good algorithm for searching for a file on a computer starting at the root directory and searching through all folders.
    Should i search the root folder first, then start searching the subfolders or should i go to the deepest subfolder and start searching there?

    any pseudo code would be a great help.

    Thanks.
    Could you please post a link of the information that you found on msdn? I can't seem to find any usefull information there.

  11. #11
    Unregistered
    Guest
    http://msdn.microsoft.com/library/de...y_category.asp

    check out the system calls...

    also here is an example of a program to find .c files....

    http://msdn.microsoft.com/library/de..._Functions.asp

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. accessing all files in a folder.
    By pastitprogram in forum C++ Programming
    Replies: 15
    Last Post: 04-30-2008, 10:56 AM
  2. Formatting the contents of a text file
    By dagorsul in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2008, 12:36 PM
  3. Help Required!!!!!
    By bobthebullet990 in forum C Programming
    Replies: 14
    Last Post: 11-27-2005, 02:56 PM
  4. Reading a file, sorting and counting contents, help?
    By mmmm_strawberri in forum C Programming
    Replies: 14
    Last Post: 04-04-2005, 01:21 AM
  5. Reading Contents of Edit Control up to a Certain Character
    By maththeorylvr in forum Windows Programming
    Replies: 1
    Last Post: 02-19-2005, 05:26 AM

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