searching files in directory

This is a discussion on searching files in directory within the Windows Programming forums, part of the Platform Specific Boards category; i need to search directory for files of specific type, for example txt files, and i need to search it ...

  1. #1
    Registered User lobo's Avatar
    Join Date
    Oct 2001
    Posts
    71

    Thumbs down searching files in directory

    i need to search directory for files of specific type, for example txt files, and i need to search it alphabetically.
    i tried to use FindFirstFile() and FindNextFile() (or so...oh my memory ), and it work somewhat...strange it created list like:

    (file) a, b, c, u, v, z, o, p etc,

    not alphabetical one and i couldn't figure out what kind of sort was it if any. I tried FindFirstFileEx() with some enhanced abilities too, but without change. Am i using wrong functions/parameters or what? please if anybody has experience with things like this, let me know about any way to do it...

  2. #2
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,831
    Right routines. What was in the directory you were logging and what did you specify as your filemask to search for?
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  3. #3
    Registered User
    Join Date
    Sep 2001
    Posts
    164
    The FindFirstFile etc. functions does not sort the files. You have to sort them yourself.

  4. #4
    Registered User lobo's Avatar
    Join Date
    Oct 2001
    Posts
    71
    the mask was exactly "*.gif" and it was an ordinary directory in disk like "e:\pics\gifs\"...(and full of gifs - about 200 )

    I need some function to browse specific files in directory alphabetically. If not FindFirst and co., then what? I want to know if there is some support in api for things like this...

  5. #5
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,831
    You are using the right API()'s. I just hacked up a little program. I think you'll find it returns the files in the creation date/time order.

    If you want them sorted alphabetically, I guess you'll have to sort as gliptic has indeed already suggested.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  6. #6
    Registered User lobo's Avatar
    Join Date
    Oct 2001
    Posts
    71
    i decided to create list of files in directory i'm interested in after all, it will probably be slower, but at least it will do what i need it to do
    Thank you anyway...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 4
    Last Post: 07-24-2008, 10:02 AM
  2. All files in a directory
    By cloudy in forum Linux Programming
    Replies: 1
    Last Post: 06-09-2008, 02:50 AM
  3. 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
  4. C++ std routines
    By siavoshkc in forum C++ Programming
    Replies: 33
    Last Post: 07-28-2006, 01:13 AM
  5. Dos commands hehe
    By Carp in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 01-17-2003, 02:51 PM

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