| xHarbour Reference Documentation > Function Reference |
![]() |
![]() |
![]() |
Loads file and directory information into a two-dimensional array.
Directory( <cDirSpec>, [<cAttributes>] ) --> aDirectory
Attributes for Directory()
| Attribute | Meaning |
|---|---|
| D | Include directories |
| H | Include hidden files |
| S | Include system files |
| V | Search for the DOS volume label and exclude all other files |
The function returns a two-dimensional array holding information about files that match <cDirSpec>. If no matching file is found, or if an error occurs, the return value is an empty array.
The Directory() function is used to collect file and/or directory information in a two dimensional array of five columns. Each column can be accessed using #define constants from the DIRECTRY.CH file.
Constants for the Directory() array
| Constant | Position | Description | Data type |
|---|---|---|---|
| F_NAME | 1 | File name | Character |
| F_SIZE | 2 | File size in bytes | Numeric |
| F_DATE | 3 | Creation date | Date |
| F_TIME | 4 | Creation time | Character |
| F_ATTR | 5 | File attributes | Character |
Note that <cDirSpec> can include wild card characters to specify a group of files.
| See also: | ADir(), AEval(), CurDir(), DirChange(), DirectoryRecurse(), DirRemove(), File(), FileStats(), IsDirectory(), MakeDir() |
| Category: | Directory functions , File functions |
| Header: | Directry.ch |
| Source: | rtl\direct.c |
| LIB: | xhb.lib |
| DLL: | xhbdll.dll |
// The example first retrieves information about a group of files and
// then the volume information of the C: drive
#include "Directry.ch"
PROCEDURE Main
LOCAL aDir
aDir := Directory( "*.prg" )
AEval( aDir, {|a| QOut( a[F_NAME] ) } )
aDir := Directory( "C:", "V" )
AEval( aDir[1], {|x| QOut( x ) } )
RETURN
http://www.xHarbour.com