Results 1 to 5 of 5

Thread: FindFirstFile Problems...

  1. #1

    Thread Starter
    Member
    Join Date
    Aug 1999
    Location
    West Hartford, CT, USA
    Posts
    42

    Angry FindFirstFile Problems...

    I'm using the FindFirstFile (in conjuntion with the FindNextFile) API call and it seems to be acting a little funky. I have a function that I pass a directory name to. The function will then use the FindFirstFile / FindNextFile API calls to get information on the files in the directory.

    Using the same data, sometimes it works and sometimes it doesn't. When it doesn't work, the return value is -1 (FILE_INVALID_HANDLE).

    I have tried to use the GetLastError API immediately after and always get a "0" back as the return value.

    I discovered that if I set a break point on the line that calls FindFirstFile and wait a few seconds, it's usually successful. That being the case, I added a 3.5 second delay using the SleepEx API. Again, sometimes it works, sometimes it doesn't.

    Has anyone run into a similar problem? I'm not quite sure what else to try!

    Frustrated in Connecticut.

  2. #2

    Thread Starter
    Member
    Join Date
    Aug 1999
    Location
    West Hartford, CT, USA
    Posts
    42
    It just occurred to me that the actual directory resides on a Linux machine - I have it on a mapped drive. I wonder if there's a "break-down" in communicating the long filename somehow.

    Windows NT lists a "MS-DOS" name for these directories and maybe I need to reference it this way.

    My preference would be to access it using the LFN that I see on my system here...

    Any thoughts?

  3. #3
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    There is an API, GetLongFileName, which gets long names from short 8.3 ones (I think, if not who knows where I picked it up). You may want to look into it.
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  4. #4
    Member
    Join Date
    Sep 2001
    Location
    Australia
    Posts
    36
    G'day,

    I have an app which recursively uses FindFirst & next API's no problems at all. To search say, all the C: drive. Mind you, mine only searches under windows, I have not tried searching under something like Linux.

    I think that FindFirstFile returns -1 if it finds nothing in the path that you specify....

    And FindNextFile returns 0 when it strikes an error or no more objects (files/directories)

    When you pass your path to FindfirstFile does it have an Asterix after it ?? eg.

    C:\*

    Is a valid path that I pass to mine, no probs at all.

    BG

  5. #5

    Thread Starter
    Member
    Join Date
    Aug 1999
    Location
    West Hartford, CT, USA
    Posts
    42
    The fist thing my function does is examine the directory path passed in. It will automatically format it to:

    DRIVE:\PATH1\PATH2\PATH3\*.*

    There are files in the directories where it's failing. The thing that bothers me is that it's inconsistent. It works on different directories diffferent times! Like I said, I suspect that it has something to do with the fact that they're mapped to a Linux machine. I will look into the GetLongFileName API to see if it gets me any where.

    In case it helps anyone, some of the directories are:

    J:\Bq\Cgs87\Distribution Files\Help\
    J:\Bq\Cgs87\Distribution Files\SpecialDLL - SelfReg\

    J: in this case is a mapped drive (to somthing like \\MACHINE\PD).

    I expanded the path name to make sure that it didn't exceed the MAX_PATH constant (I believe it's 260).

    In some cases, it will fail on the directory "HELP." In others, it will fail on the directory "SpecialDLL - SelfReg". In yet others, it will succeed in both cases.

    Pretty bizarre stuff..

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width