The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.
We recommend using Visual Studio 2017

_findnext, _findnext32, _findnext32i64, _findnext64, _findnext64i32, _findnexti64, _wfindnext, _wfindnext32, _wfindnext32i64, _wfindnext64, _wfindnext64i32, _wfindnexti64


The new home for Visual Studio documentation is Visual Studio 2017 Documentation on

The latest version of this topic can be found at _findnext, _findnext32, _findnext32i64, _findnext64, _findnext64i32, _findnexti64, _wfindnext, _wfindnext32, _wfindnext32i64, _wfindnext64, _wfindnext64i32, _wfindnexti64.

Find the next name, if any, that matches the filespec argument in a previous call to _findfirst, and then alter the fileinfo structure contents accordingly.

int _findnext(  
   intptr_t handle,  
   struct _finddata_t *fileinfo   
int _findnext32(  
   intptr_t handle,  
   struct _finddata32_t *fileinfo   
int _findnext64(  
   intptr_t handle,  
   struct __finddata64_t *fileinfo   
int _findnexti64(  
   intptr_t handle,  
   struct __finddatai64_t *fileinfo   
int _findnext32i64(  
   intptr_t handle,  
   struct _finddata32i64_t *fileinfo   
int _findnext64i32(  
   intptr_t handle,  
   struct _finddata64i32_t *fileinfo   
int _wfindnext(  
   intptr_t handle,  
   struct _wfinddata_t *fileinfo   
int _wfindnext32(  
   intptr_t handle,  
   struct _wfinddata32_t *fileinfo   
int _wfindnext64(  
   intptr_t handle,  
   struct _wfinddata64_t *fileinfo   
int _wfindnexti64(  
   intptr_t handle,  
   struct _wfinddatai64_t *fileinfo   
int _wfindnext32i64(  
   intptr_t handle,  
   struct _wfinddatai64_t *fileinfo   
int _wfindnext64i32(  
   intptr_t handle,  
   struct _wfinddata64i32_t *fileinfo   


Search handle returned by a previous call to _findfirst.

File information buffer.

If successful, returns 0. Otherwise, returns –1 and sets errno to a value indicating the nature of the failure. Possible error codes are shown in the following table.

Invalid parameter: fileinfo was NULL. Or, the operating system returned an unexpected error.

No more matching files could be found.

Not enough memory or the file name's length exceeded MAX_PATH.

If an invalid parameter is passed in, these functions invoke the invalid parameter handler, as described in Parameter Validation.

You must call _findclose after you are finished using either the _findfirst or _findnext function (or any variants). This frees up resources used by these functions in your application.

The variations of these functions with the w prefix are wide-character versions; otherwise, they are identical to the corresponding single-byte functions.

Variations of these functions support 32-bit or 64-bit time types and 32-bit or 64-bit file sizes. The first numerical suffix (32 or 64) indicates the size of the time type used; the second suffix is either i32 or i64, indicating whether the file size is represented as a 32-bit or 64-bit integer. For information about which versions support 32-bit and 64-bit time types and file sizes, see the following table. The variations that use a 64-bit time type allow file-creation dates to be expressed up through 23:59:59, December 31, 3000, UTC; whereas those using 32-bit time types only represent dates through 23:59:59 January 18, 2038, UTC. Midnight, January 1, 1970, is the lower bound of the date range for all these functions.

Unless you have a specific reason to use the versions that specify the time size explicitly, use _findnext or _wfindnext or, if you need to support file sizes greater than 3 GB, use _findnexti64 or _wfindnexti64. All these functions use the 64-bit time type. In previous versions, these functions used a 32-bit time type. If this is a breaking change for an application, you might define _USE_32BIT_TIME_T to get the old behavior. If _USE_32BIT_TIME_T is defined, _findnext, _finnexti64 and their corresponding Unicode versions use a 32-bit time.

Time Type and File Length Type Variations of _findnext

Functions_USE_32BIT_TIME_T defined?Time typeFile length type
_findnext, _wfindnextNot defined64-bit32-bit
_findnext, _wfindnextDefined32-bit32-bit
_findnext32, _wfindnext32Not affected by the macro definition32-bit32-bit
_findnext64, _wfindnext64Not affected by the macro definition64-bit64-bit
_findnexti64, _wfindnexti64Not defined64-bit64-bit
_findnexti64, _wfindnexti64Defined32-bit64-bit
_findnext32i64, _wfindnext32i64Not affected by the macro definition32-bit64-bit
_findnext64i32, _wfindnext64i32Not affected by the macro definition64-bit32-bit

Generic-Text Routine Mappings

Tchar.h routine_UNICODE and _MBCS not defined_MBCS defined_UNICODE defined
FunctionRequired header
_wfindnext<io.h> or <wchar.h>
_wfindnext32<io.h> or <wchar.h>
_wfindnext64<io.h> or <wchar.h>
_wfindnexti64<io.h> or <wchar.h>
_wfindnext32i64<io.h> or <wchar.h>
_wfindnext64i32<io.h> or <wchar.h>

For more compatibility information, see Compatibility in the Introduction.

All versions of the C run-time libraries.

Not applicable. To call the standard C function, use PInvoke. For more information, see Platform Invoke Examples.

System Calls
Filename Search Functions