DOCUMENT:Q166505 11-FEB-2002 [visualc] TITLE :DOC: FindNextFile Returns 0 for Last File Found PRODUCT :Microsoft C Compiler PROD/VER::4.2,5.0,6.0 OPER/SYS: KEYWORDS:kbusage kbdocfix kbdocerr kbFileIO kbMFC kbVC420bug kbVC500bug kbVC600bug kbGrpDSMFCATL ====================================================================== ------------------------------------------------------------------------------- The information in this article applies to: - The Microsoft Foundation Classes (MFC), used with: - Microsoft Visual C++, 32-bit Enterprise Edition, versions 4.2, 5.0, 6.0 - Microsoft Visual C++, 32-bit Professional Edition, versions 4.2, 5.0, 6.0 - Microsoft Visual C++, 32-bit Learning Edition, version 6.0 ------------------------------------------------------------------------------- SUMMARY ======= The documentation for CFileFind::FindNextFile, CFtpFileFind::FindNextFile, and CGopherFileFind::FindNextFile in the Class Library Reference with Visual C++ is incorrect. The documentation states: Return Value Nonzero if successful; otherwise 0. To get extended error information, call the Win32 function GetLastError. The documentation should read: Return Value Nonzero if there are more files; zero if the file found is the last one in the directory or if an error occurred. To get extended error information, call the Win32 function GetLastError. If the file found is the last file in the directory, or if no matching files can be found, the GetLastError function returns ERROR_NO_MORE_FILES. MORE INFORMATION ================ The code below shows how to use CFileFind::FindNextFile to find every file in a directory. Sample Code ----------- CFileFind finder; BOOL bWorking = finder.FindFile("*.*"); while (bWorking) { bWorking = finder.FindNextFile(); // Do processing here } REFERENCES ========== See the CFileFind overview in the Visual C++ documentation. Additional query words: FindNextFile FileFind CfileFind CftpFileFind CGopherFileFind ====================================================================== Keywords : kbusage kbdocfix kbdocerr kbFileIO kbMFC kbVC420bug kbVC500bug kbVC600bug kbGrpDSMFCATL kbNoUpdate Technology : kbAudDeveloper kbMFC Version : :4.2,5.0,6.0 Issue type : kbbug Solution Type : kbpending ============================================================================= THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY. Copyright Microsoft Corporation 2002.