Click or drag to resize

ADir Function

Fill a series of arrays with directory information. Note:  ADir() is a compatibility function and therefore not recommended.  It is superseded by the Directory() function, which returns all file information in a multidimensional array.

Namespace:  XSharp.RT
Assembly:  XSharp.RT (in XSharp.RT.dll) Version: 2.10
Syntax
 FUNCTION ADir(
	 cFileSpec AS USUAL,
	 acFileNames AS USUAL,
	 anSizes AS USUAL,
	 adDates AS USUAL,
	 acTimes AS USUAL,
	 acAttributes AS USUAL
) AS DWORD
View Source

Parameters

cFileSpec
Type: Usual
The file specification for the directory search.  Besides a file name, this specification may include an optional drive, directory, and extension.  The file name and extension may include the standard wildcard characters (* and ?).  If you do not specify a drive and directory, this function uses the SetDefault() setting.
acFileNames
Type: Usual
The array to fill with the file names matching <cFileSpec>.  Each element will contain the file name and extension as a string, in all uppercase letters.
anSizes
Type: Usual
The array to fill with the sizes of the corresponding files in <acFileNames>.
adDates
Type: Usual
The array to fill with the dates of the corresponding files in <acFileNames>.
acTimes
Type: Usual
The array to fill with the times of the corresponding files in <acFileNames>, in the form hh:mm:ss.
acAttributes
Type: Usual
The array to fill with attributes of the corresponding files in <acFileNames>.  If <acAttributes> is specified, hidden, system, and directory files are included as well as normal files.  If <acAttributes> is not specified, only normal files are included.

Return Value

Type: UInt32
The number of files matching the directory skeleton described in <cFileSpec>.
Remarks
ADir() performs two basic operations.  First, it returns the number of files matching the file specification.  Second, it fills a series of arrays with file names, sizes, dates, times, and attributes.  Note that all of the array arguments must exist prior to calling this function and must be of a large enough size to hold the function results.
Tip Tip
If you specify <acAttributes>, and <cFileSpec> contains a pattern, such as "*.*" or "*.", that matches directory names, directories are included in <acFileNames>.  They are indicated with an attribute value of "D."  If ADir() is executed within a subdirectory, the first two entries of <acFileNames> are "." and "..", the parent and current directory aliases.  The date and time of last update are reported for directories, but the size of a directory is always 0.
Examples
This example creates an array to hold the names of all .TXT files in the current default directory, then uses AEval() to list them to the console:
X#
LOCAL aFiles AS ARRAY
aFiles := ArrayCreate(ADir("*.txt"))
ADir("*.txt", aFiles)
AEval(aFiles, {|element| QOut(element)})
See Also