|
GetFolder() 
Returns an array listing of information about
files in a specified folder.
Syntax
GetFolder(<cDrivePath>, [<cAttributes>])
--> aFileList
Arguments
<cDrivePath> --> Identifies the drive,
folder and file specification for the examination of a folder.
<cAttributes> --> Optionally specifies
the inclusion of files with special attributes in the returned
information. cAttributes may contain one or more character codes.
Refer to the table below for an explanation of these character
codes:
|
Attribute
Character
|
Meaning
|
|
H
|
Include hidden files.
|
|
S
|
Include system files.
|
|
D
|
Include folders.
|
|
V
|
Search for the volume label and excluse all other
files.
|
Normal files are always included in the search unless
you specify V in the cAttributes parameter.
Returns
Returns an array containing a listing of matching
files. Each list entry contains 5 further array elements. The 5
array elements are explained in the following table:
|
Position
|
Contents
|
Type
|
|
1
|
The file name without the file path.
|
Character
|
|
2
|
The file size.
|
Numeric
|
|
3
|
The creation date in DD/MM/YY format.
|
Date
|
|
4
|
The creation time in HH:MM:SS format.
|
Character
|
|
5
|
The file's attribute flags as character
values.
|
Character
|
If no files are found matching the drive path or the
drive path does not exist, an empty list will be returned.
Description
GetFolder() is an environment function that
returns information about files in the specified folder.
Example
The following statements retrieve a file list and
displays how many files are found in the folder:
Declare aFileList Type
Array
aFileList :=
GetFolder("C:\")
Echo(Len(aFileList))
Return the size of the stock table in the
currently open company:
Declare aFileList Type Array
aFileList := GetFolder(PathCompany() +
"STOCK.DBF")
If Len(aFileList) = 1
Echo(aFileList[1,2])
Endif
Note that the first element number of the array
is the position of the file in the list. The second element
references the file's name, size, creation date, creation time, and
attributes:
* Retrieve 3rd file's
size:
nSize :=
aFileList[3,2])
* Retrieve 10th file's
creation date:
dDate :=
aFileList[10,3])
* Retrieve 8th file's
attributes:
dDate :=
aFileList[8,5])
Use the
Len() function
to determine how many elements are contained in the array. If you
attempt to reference an array entry that is larger than the list or
a property of the entry beyond 5, CBS will raise an error
condition.
____________________________
Related Topics
Business
Function List
InputFile()
PathCompany()
PathData()
PathProgram()
|