Click to Rate and Give Feedback
MSDN
MSDN Library
Windows Development
Local File Systems
File Management
 WIN32_FIND_DATA structure
WIN32_FIND_DATA structure

Applies to: desktop apps | Metro style apps

Contains information about the file that is found by the FindFirstFile, FindFirstFileEx, or FindNextFile function.

Syntax

typedef struct _WIN32_FIND_DATA {
  DWORD    dwFileAttributes;
  FILETIME ftCreationTime;
  FILETIME ftLastAccessTime;
  FILETIME ftLastWriteTime;
  DWORD    nFileSizeHigh;
  DWORD    nFileSizeLow;
  DWORD    dwReserved0;
  DWORD    dwReserved1;
  TCHAR    cFileName[MAX_PATH];
  TCHAR    cAlternateFileName[14];
} WIN32_FIND_DATA, *PWIN32_FIND_DATA, *LPWIN32_FIND_DATA;

Members

dwFileAttributes

The file attributes of a file.

For possible values and their descriptions, see File Attribute Constants.

ftCreationTime

A FILETIME structure that specifies when a file or directory was created.

If the underlying file system does not support creation time, this member is zero.

ftLastAccessTime

A FILETIME structure.

For a file, the structure specifies when the file was last read from, written to, or for executable files, run.

For a directory, the structure specifies when the directory is created. If the underlying file system does not support last access time, this member is zero.

On the FAT file system, the specified date for both files and directories is correct, but the time of day is always set to midnight.

ftLastWriteTime

A FILETIME structure.

For a file, the structure specifies when the file was last written to, truncated, or overwritten, for example, when WriteFile or SetEndOfFile are used. The date and time are not updated when file attributes or security descriptors are changed.

For a directory, the structure specifies when the directory is created. If the underlying file system does not support last write time, this member is zero.

nFileSizeHigh

The high-order DWORD value of the file size, in bytes.

This value is zero unless the file size is greater than MAXDWORD.

The size of the file is equal to (nFileSizeHigh * (MAXDWORD+1)) + nFileSizeLow.

nFileSizeLow

The low-order DWORD value of the file size, in bytes.

dwReserved0

If the dwFileAttributes member includes the FILE_ATTRIBUTE_REPARSE_POINT attribute, this member specifies the reparse point tag.

Otherwise, this value is undefined and should not be used.

For more information see Reparse Point Tags.

IO_REPARSE_TAG_CSV (0x80000009)
IO_REPARSE_TAG_DEDUP (0x80000013)
IO_REPARSE_TAG_DFS (0x8000000A)
IO_REPARSE_TAG_DFSR (0x80000012)
IO_REPARSE_TAG_HSM (0xC0000004)
IO_REPARSE_TAG_HSM2 (0x80000006)
IO_REPARSE_TAG_MOUNT_POINT (0xA0000003)
IO_REPARSE_TAG_NFS (0x80000014)
IO_REPARSE_TAG_SIS (0x80000007)
IO_REPARSE_TAG_SYMLINK (0xA000000C)
IO_REPARSE_TAG_WIM (0x80000008)
dwReserved1

Reserved for future use.

cFileName

The name of the file.

cAlternateFileName

An alternative name for the file.

This name is in the classic 8.3 file name format.

Remarks

If a file has a long file name, the complete name appears in the cFileName member, and the 8.3 format truncated version of the name appears in the cAlternateFileName member. Otherwise, cAlternateFileName is empty. If the FindFirstFileEx function was called with a value of FindExInfoBasic in the fInfoLevelId parameter, the cAlternateFileName member will always contain a NULL string value. This remains true for all subsequent calls to the FindNextFile function. As an alternative method of retrieving the 8.3 format version of a file name, you can use the GetShortPathName function. For more information about file names, see File Names, Paths, and Namespaces.

Not all file systems can record creation and last access times, and not all file systems record them in the same manner. For example, on the FAT file system, create time has a resolution of 10 milliseconds, write time has a resolution of 2 seconds, and access time has a resolution of 1 day. The NTFS file system delays updates to the last access time for a file by up to 1 hour after the last access. For more information, see File Times.

Requirements

Minimum supported client

Windows XP

Minimum supported server

Windows Server 2003

Header

MinWinBase.h (include Windows.h);
WinBase.h on Windows Server 2008 R2, Windows 7, Windows Server 2008, Windows Vista, Windows Server 2003, and Windows XP (include Windows.h)

Unicode and ANSI names

WIN32_FIND_DATAW (Unicode) and WIN32_FIND_DATAA (ANSI)

See also

File Attribute Constants
File Names, Paths, and Namespaces
File Times
FILETIME
FindFirstFile
FindFirstFileEx
FindNextFile
FileTimeToLocalFileTime
FileTimeToSystemTime
GetShortPathName

 

 

Send comments about this topic to Microsoft

Build date: 4/17/2012

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Reparse Points for Directory Recursion      veshdog1871 ... Thomas Lee   |   Edit   |   Show History
If you utilize MAX_PATH instead of the Unicode 32,767 size limit, you will overrun your buffer if you don't account for the reparse points.

if ((lpFindData->dwFileAttributes &;; FILE_ATTRIBUTE_DIRECTORY) )
if(!(lpFindData->dwFileAttributes &;; FILE_ATTRIBUTE_REPARSE_POINT))
{
RecursivePathSearchFunction(path,wcslen(path));
}
Tags What's this?: Add a tag
Flag as ContentBug
No path returned      jac_goudsmit   |   Edit   |   Show History
The cFileName field in this structure will not include a path, even if a path was used in the call to FindFirstFile/FindNextFile. So if you call FindFirstFile("C:\Windows\System32\*", &;;finddata), finddata may contain e.g. "drivers" or "cmd.exe" but not "C:\Windows\System32\drivers" or "C:\Windows\System32\cmd.exe".
Tags What's this?: Add a tag
Flag as ContentBug
WIN32_FIND_DATA and negative file sizes.      Bart_K   |   Edit   |   Show History
You should use UINT (Unsigned Integer) to receive a DWORD value. DWORD is a 32-bit unsigned integer. The range is 0 through 4294967295 decimal. INT is a 32-bit signed integer. The range is -2147483648 through 2147483647 decimal. UINT is an unsigned INT. The range is 0 through 4294967295 decimal. Wrong implementation in Microsoft .NET: an INT is used for receiving DWORD values at the mscorlib.dll .NET library, which leads to faulty results. Namespace: Microsoft.Win32.Win32Native+WIN32_FIND_DATA The same problem is found at the System.Runtime.InteropServices.ComTypes.FILETIME structure, leading to faulty results here also. References: http://mcdrummerman.wordpress.com/2010/07/13/win32_find_data-and-negative-file-sizes/ http://www.pinvoke.net/default.aspx/Structures/WIN32_FIND_DATA.html
Tags What's this?: Add a tag
Flag as ContentBug
Processing
© 2012 Microsoft. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker