function FileEnum(const APath: string; ADest: TStringList; const ARecursive: boolean = false): boolean;

 

Enumerates the files (and folders/directories) that match the APath criteria, and puts the resulting list into the ADest variable.

Returns true if the command was executed successfully, false if there were problems (like, for example, trying to enumerate e non existent path).

Please, be aware that the resulting list (ADest) may be empty even if the function returns true. This happens when enumerating a directory that doesn't contain any file or subdirectories.

Set ARecursive to true if you wish to enumerate all files and folders also contained in all subdirectories of the specified location.

 

Example, find all Word documents (*.docx files) inside a certain directory on the server:

 
var
  MyList: TStringList;
begin
  MyList := TStringList.Create;
  FileExum('C:\Data\*.docx', MyList, false);
  // do something with MyList... and then...
  MyList.Free;
end.