DIR()

DIR()

Top  Previous  Next

 

The DIR() function returns the contents of an operating system directory.

 

 

Format

 

DIR(pathname)

 

where

 

pathnameidentifies the operating system directory to be processed.

 

 

The DIR() function returns a dynamic array with one field per entry in the specified directory. Each field contains the following items separated by value marks:

Value 1The item name. On platforms with case insensitive file names, the text returned preserves the casing used by the underlying operating system.
Value 2The item type. This is F for a file or D for a directory.
Value 3File modes. On Windows systems, this is a collection of letters representing the file attributes:

A = archive

C = compressed

H = hidden

R = read only

S = system

T = temporary

On other platforms, this value contains the file permissions as a decimal value.

Value 4The date/time modified for the item as an epoch value.
Value 5The file size in bytes. On Windows systems, this is zero for a directory.

 

The standard . and .. directory entries are not returned.

 

Applications should not assume that this structure will remain unchanged. Additional values may appear in future releases.

 

Because the DIR() function returns data for the entire directory as a single string, it could fail for very large directories.

 

 

Example

 

FILES = DIR('C:\MYDIR')

NUM.FILES = DCOUNT(FILES, @FM)

FOR I = 1 TO NUM.FILES

  IF FILES<I,2> = 'F' THEN DISPLAY FILES<I,1>

NEXT I

 

The above example lists all the files in C:\MYDIR, omitting subdirectories.