FindNextFile

This is a discussion on FindNextFile within the Windows Programming forums, part of the Platform Specific Boards category; I just realized that if a fatal error occurs (however unlikely) the directories won't be closed properly. I added a ...

  1. #16
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    I just realized that if a fatal error occurs (however unlikely) the directories won't be closed properly. I added a helper class to take care of that, though.

  2. #17
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,856
    Quote Originally Posted by bithub View Post
    Since the documentation for FindNextFile() doesn't say anything one way or the other, relying on it to return ERROR_SUCCESS is bad program design. There is no requirement at all that the function set ERROR_SUCCESS on a successful call.
    Which is why I call

    SetLastError(ERROR_SUCCESS);

    after I have found and processed a file successfully (and just before I check for more files).
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  3. #18
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,856
    FindNextFile() docs say it sets the errors.

    Quote Originally Posted by MSDN
    If the function fails, the return value is zero. To get extended error information, call GetLastError. If no matching files can be found, the GetLastError function returns ERROR_NO_MORE_FILES.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. FindFirstFile and FindNextFile
    By scwizzo in forum Windows Programming
    Replies: 15
    Last Post: 03-12-2008, 04:50 PM
  2. Msdn example code (FindFirstFile, FindNextFile
    By Probose in forum Windows Programming
    Replies: 2
    Last Post: 09-22-2006, 04:16 PM
  3. FindNextFile()
    By siavoshkc in forum C++ Programming
    Replies: 9
    Last Post: 03-03-2006, 08:47 AM
  4. m_dir = system("dir c:")
    By Ray Schmidt in forum Windows Programming
    Replies: 4
    Last Post: 03-09-2003, 08:39 AM
  5. directories, lccwin32 and findnextfile
    By ggs in forum Windows Programming
    Replies: 6
    Last Post: 07-23-2002, 10:00 PM

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