File Searching API functions

This is a discussion on File Searching API functions within the Windows Programming forums, part of the Platform Specific Boards category; Please bare with me here, I have a couple questions I've been saving up on file searching functions on MSDN: ...

  1. #1
    Registered Abuser
    Join Date
    Jun 2006
    Location
    Toronto
    Posts
    591

    File Searching API functions

    Please bare with me here, I have a couple questions I've been saving up on file searching functions on MSDN:

    I've been browsing MSDN in the file management section looking for good solutions for finding files in directories by file name AND attributes, but have not found one yet. I am trying to implement a file search that would search through a directory and find only subdirectories, but since FindFirstFile will only search by name and not by attribute, the only solution I can think of is manually stepping through each file in the directory and checking if it has the FILE_ATTRIBUTE_DIRECTORY flag set... which seems a bit ineffecient. Is there any other function/method I could implement to find only subdirectories within a directory?

    Also, complementary to the above problem, I am trying to find a function that will return the number of files contained in a directory (without having to manually step through counting as in the above example). Is there something like a "GetNumberOfFilesInDirectory"?

    Thirdly, I also need to obtain the last access time of a directory, and thought GetFileAttributesEx() would be a good way to do this, except it states here (GetFileAttributesEx()) that the fLastAccessTime member "For a directory, ... specifies when the directory is created." Now, I'm hoping this is a typo because I'm finding it hard to believe they would store the creation time in anything but the fCreationTime member, and would reserve the fLastAccesTime member for.. well... what its named for!!

    My final question is on recursive directory searching. Is there any API function that will recursively search a directory and all subdirectories for a specified file/directory? I was thinking of creating a FindFirstFile recursive function, but was hoping microsoft might have already supplied one, any luck?

    Thanks for reading and any of your suggestions!

  2. #2
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,457
    Look at this http://msdn.microsoft.com/library/de...older_info.asp

    You may want to use some interfaces exported by the shell to wotk with folders. The code can be a little bit more complicated, but functions provided by the shell can be more powerful
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  3. #3
    Registered Abuser
    Join Date
    Jun 2006
    Location
    Toronto
    Posts
    591
    Thanks! You were definately right about the complicated part... I went through some of those interfaces and got immediately lost; but yea, just from reading some of the namespace APIs and SH functions, I can see how powerful and useful they are. Thanks a lot!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. windows api file functions
    By xixpsychoxix in forum Windows Programming
    Replies: 8
    Last Post: 07-01-2008, 04:26 PM
  2. Basic text file encoder
    By Abda92 in forum C Programming
    Replies: 15
    Last Post: 05-22-2007, 01:19 PM
  3. Encryption program
    By zeiffelz in forum C Programming
    Replies: 1
    Last Post: 06-15-2005, 03:39 AM
  4. Simple File encryption
    By caroundw5h in forum C Programming
    Replies: 2
    Last Post: 10-13-2004, 10:51 PM

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