function ListFilesR(directory, mask)


The ListFilesR method retrieves the list of files (not sub-directories) contained inside the specified directory and all of its sub-directories.
The result of this function is returned as a JavaScript array of objects. Each object is of DirListItem type.

Once a resulting array has been obtained, you can use the typical JavaScript ways to iterate over it, and check the various property of each one of its items.


The directory parameter must specify an existing directory.
The mask parameter must specify to file-mask to match while searching, wildcards are supported (for example: *.docx).


This function is recursive, therefore it will return all matching files from directory as well as from all of directory's sub-directories.


Example 1 (one way to iterate over a directory list, using a for cycle):

{
 var scli = new SftpClient();
 scli.Host = 'your.sftpserver.com:22';
 scli.User = 'someusername';
 scli.KeyFile = './my_id.rsa';
 if (scli.Connect()) {
  dirList = scli.ListFilesR('/docs', '*.docx');
  for (var i = 0; i < dirList.length; i++) {
   Log(dirList[i].Name);
  }
  scli.Close();
 }
 scli = null
}


Example 2 (a different way to iterate over a directory list, using forEach):

{
 var scli = new SftpClient();
 scli.Host = 'your.sftpserver.com:22';
 scli.User = 'someusername';
 scli.KeyFile = './my_id.rsa';
 if (scli.Connect()) {
  dirList = scli.ListFilesR('/docs', '*.xlsx');
  dirList.forEach(myFunction);
  function myFunction(item, index, array) {
    Log(item.Name + ' [' + item.Size + ' bytes] [' + item.Type + ']');
  }
  scli.Close();
 }
 scli = null
}