IntPtr hFile = FindFirstFileEx(
pattern,
findInfoLevel,
out findData,
FINDEX_SEARCH_OPS.FindExSearchNameMatch,
IntPtr.Zero,
additionalFlags);
int error = Marshal.GetLastWin32Error();
if (hFile.ToInt32() != -1)
{
do
{
if ((findData.dwFileAttributes & FileAttributes.Directory) != FileAttributes.Directory)
{
Console.WriteLine("Found file {0}", findData.cFileName);
}
}
while (FindNextFile(hFile, out findData));
FindClose(hFile);
}
Alternative Managed API:
The FileInfo() class provides managed access to this information. As with all .NET file handling (as of framework 4) it is constrained in terms of the length of filename allowed.
The FindFirstFileEx API
12/18/2010 3:54:44 PM - -41.132.39.148
Defines values that are used with the FindFirstFileEx function to specify the information level of the returned data.
11/18/2010 9:49:37 PM - -64.238.244.146
Defines values that are used with the FindFirstFileEx function to specify the type of filtering to perform.
11/18/2010 9:50:21 PM - -64.238.244.146
Contains information about the file that is found by the FindFirstFile, FindFirstFileEx, or FindNextFile function.
9/27/2010 5:30:16 PM - -60.242.128.193
Please edit this page!
Do you have...
helpful tips or sample code to share for using this API in managed code?
corrections to the existing content?
variations of the signature you want to share?
additional languages you want to include?
Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).