FindNextFileW Function
Retrieves information about the next file or directory found by a file search initiated by a call to the FindFirstFileW function.
Syntax
BOOL FindNextFileW(
HANDLE hFindFile,
LPWIN32_FIND_DATAW lpFindFileData
);
Parameters
hFindFileA handle to the search returned by a previous call to the FindFirstFileW function. The handle must have the
FILE_SKIP_SET_REPARSE_POINTSandFILE_SKIP_SYMBOLIC_LINKSaccess rights.lpFindFileDataA pointer to a WIN32_FIND_DATAW structure that receives information about the found file or directory.
Return value
If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. To get extended error information, call GetLastError.
Remarks
The FindFirstFileW function starts the search and returns a handle and information about the first file or directory that matches the specified search criteria. The FindNextFileW function retrieves subsequent matches.
A typical loop looks like this:
HANDLE hFind = INVALID_HANDLE_VALUE;
WIN32_FIND_DATAW fdFind;
hFind = FindFirstFileW(TEXT("C:\\*.*"), &fdFind);
if (hFind != INVALID_HANDLE_VALUE)
{
do
{
// Process the file/directory found in fdFind
wprintf(TEXT(" %s %s\n"),
fdFind.cAlternateFileName,
fdFind.cFileName);
} while (FindNextFileW(hFind, &fdFind));
FindClose(hFind);
}
Note
When you are finished with the search, call the FindClose function to close the search handle.
The FindNextFileW function is sensitive to the locale settings of the current user. It will match file names according to the rules of the current locale.
To search for files with specific attributes, use the FindFirstFileExW function.
Requirements
| Requirement | Value |
|---|---|
| Minimum supported client | Windows 2000 Professional [desktop apps only] |
| Minimum supported server | Windows 2000 Server [desktop apps only] |
| Target Platform | Windows |
| Header | ioapi.h (include Fileapi.h) |
| Library | Kernel32.lib |
| DLL | Kernel32.dll |
| Unicode and ANSI Versions | FindNextFileW (Unicode) and FindNextFileA (ANSI) |