Microsoft KB Archive/166505

= DOC: FindNextFile Returns 0 for Last File Found =

Article ID: 166505

Article Last Modified on 11/21/2006

-

APPLIES TO

 Microsoft Foundation Class Library 4.2, when used with:  Microsoft Visual C++ 4.2 Enterprise Edition

 Microsoft Visual C++ 5.0 Enterprise Edition

 Microsoft Visual C++ 6.0 Enterprise Edition

 Microsoft Visual C++ 4.2 Professional Edition</li></ul>

 Microsoft Visual C++ 5.0 Professional Edition</li></ul>

 Microsoft Visual C++ 6.0 Professional Edition</li></ul>

 Microsoft Visual C++ 6.0 Standard Edition</li></ul> </li></ul>

-

<div class="notice_section">

This article was previously published under Q166505

<div class="notice_section">

<div class="summary_section">

SUMMARY
The documentation for CFileFind::FindNextFile, CFtpFileFind::FindNextFile, and CGopherFileFind::FindNextFile in the Class Library Reference with Visual C++ is incorrect. The documentation states: <pre class="fixed_text">  Return Value

Nonzero if successful; otherwise 0. To get extended error information, call the Win32 function GetLastError. The documentation should read: <pre class="fixed_text">  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.

<div class="moreinformation_section">

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 }

<div class="references_section">