FindFiles function
Syntax
FindFiles(filespec_pattern [, pathtype])
Description
Use the FindFiles function to return a list of the external file names that match the file name pattern you provide, in the location you specify.
Parameters
| Parameter | Description |
|---|---|
|
filespec_pattern |
Specify the path and file name pattern for the files you want to find. The path can be any string expression that represents a single relative or absolute directory location. The file name pattern, but not the path, can include two wildcards: * (Asterisk): matches zero or more characters at its position. ? (Question mark): matches exactly one character at its position. |
|
pathtype |
If you have prefixed a path to the file name, use this parameter to specify whether the path is an absolute or relative path. The valid values for this parameter are:
If you don’t specify pathtype the default is %FilePath_Relative. If you specify a relative path, that path is appended to the path constructed from a system-chosen environment variable. A complete discussion of relative paths and environment variables is provided in documentation on the File class. See PeopleCode API Reference: Working With Relative Paths. If the path is an absolute path, whatever path you specify is used verbatim. You must specify a drive letter and the complete path. You can’t use any wildcards when specifying a path. The Component Processor automatically converts platform-specific separator characters to the appropriate form for where your PeopleCode program is executing. On a Windows system, UNIX "/" separators are converted to "\", and on a UNIX system, Windows "\" separators are converted to "/". Note: The syntax of the file path does not depend on the file system of the platform where the file is actually stored; it depends only on the platform where your PeopleCode is executing. |
Returns
A string array whose elements are file names qualified with the same relative or absolute path you specified in the input parameter to the function.
Example
The following example finds all files in the system’s TEMP location whose names end with ".txt", then opens and processes each one in turn:
Local array of string &FNAMES;
Local file &MYFILE;
&FNAMES = FindFiles("\*.txt");
while &FNAMES.Len > 0
&MYFILE = GetFile(&FNAMES.Shift(), "R", "UTF8"); /* Open each file */
/* Process the file contents */
&MYFILE.Close();
end-while;