Function Reference


Enumerates the files and subdirectories for the specified directory with a name that matches the template

#include <WinAPIFiles.au3>
_WinAPI_EnumFiles ( $sDir [, $iFlag = 0 [, $sTemplate = '' [, $bExclude = False]]] )


$sDir The path to the directory.
$iFlag [optional] The flag that specifies whether to enumerate files, subdirectories, or both.
This parameter can be one of the following values:
    0 - Enumerate both files and subdirectories (Default).
    1 - Enumerate files only.
    2 - Enumerate subdirectories only.
$sTemplate [optional] A template that using to enumerating files and directories. For example, "*.jpe;*.jpeg;*.jpg".
$bExclude [optional] Specifies whether the specified template is used to exclude files, valid values:
    True - The files matching the template will not be enumerated.
    False - The only those files that match the template will be enumerated (Default).

Return Value

Success: a 2D array containing the following information:
    [0][0] - Number of rows in array (n)
    [0][i] - Unused
    [n][0] - The name of the file.
    [n][1] - The time (UTC) when the file was created.
    [n][2] - The time (UTC) when the file was last accessed.
    [n][3] - The time (UTC) when the file was last changed.
    [n][4] - The size of the file, in bytes.
    [n][5] - The allocation size of the file, in bytes.
    [n][6] - The file attributes ($FILE_ATTRIBUTE_*).
Failure: Sets the @error flag to non-zero, @extended flag may contain the NTSTATUS error code.


If the target directory is empty or no files matched the specified criteria, the function still returns an array where zeroth array element set to 0.

See Also

Search ZwQueryDirectoryFile in MSDN Library.


#include <Array.au3>
#include <WinAPIFiles.au3>

Local $aData = _WinAPI_EnumFiles(@SystemDir, 1, '*.ax;*.cpl;*.dll;*.drv;*.exe;*.ocx;*.scr')

_ArrayDisplay($aData, '_WinAPI_EnumFiles')