dir( )
Topic group Related topics Example
Fills the array with five characteristics of specified files: name, size, modified date, modified time, and file attribute(s). Returns the number of files whose characteristics are stored.
Syntax
<oRef>.dir([<filename skeleton expC> [, <DOS file attribute list expC>]])
<oRef>
A reference to the array in which you want to store the file information. dir( ) will automatically redimension or increase the size of the array to accommodate the file information, if necessary.
<filename skeleton expC>
The file-name pattern (using wildcards) describing the files whose information you want to store to <oRef>.
<file attribute list expC>
The letter or letters D, H, S, and/or V representing one or more file attributes.
If you want to specify a value for <file attribute expC>, you must also specify a value or "*.*" for <filename skeleton expC>.
The meaning of each attribute is as follows:
Character |
Meaning |
D |
Directories |
H |
Hidden files |
S |
System files |
V |
Volume label |
If you supply more than one letter for <file attribute expC>, include all the letters between one set of quotation marks, for example, aFiles.dir("*.*", "HS").
Property of
Array
Description
Use dir( ) to store information about files to an array, which is dynamically resized so all returned information fits in the array. The resulting array is always a two-dimensional array, unless there are no files, in which case the array is not modified.
Without <filename skeleton expC>, dir( ) stores information about all files in the current directory, unless they are hidden or system files. For example, if you want to return information only on DBF tables, use "*.DBF" as <filename skeleton expC>.
If you want to include directories, hidden files, or system files in the array, use <file attribute expC>. When D, H, or S is included in <file attribute expC>, all directories, hidden files, and/or system files (respectively) that match <filename skeleton expC> are added to the array.
When V is included in <file attribute expC>, dir( ) ignores <filename skeleton expC> as well as other characters in the attribute list, and stores the volume label to the first element of the array.
dir( ) stores the following information for each file in each row of the array. The data type for each is shown in parentheses:
Column 1 |
Column 2 |
Column 3 |
Column 4 |
Column 5 |
File name |
Size |
Modified date |
Modified time |
File attribute(s) |
The last column (file attribute) can contain one or more of the following file attributes, in the order shown:
Attribute |
Meaning |
R |
Read-only file |
A |
Archive file (modified since it was last backed up) |
S |
System file |
H |
Hidden file |
D |
Directory |
If the file has the attribute, the letter code is in the column. Otherwise, there is a period. For example, a file with none of the attributes would have the following string in column 5:
.....
A read-only, hidden file would have the following string in column 5:
R..H.
Use dirExt( ) to get extended Windows® 95/98/2000/NT/ME file information.