Directory list item

DirListItem = {
  Name:      string  // fully qualified path and file name (ex: "/docs/resume.docx")
  Type:      string  // "FILE" or "DIR"
  Size:      number  // the file size (integer)
  TimeStamp: Date    // timestamp of the item, in JavaScript "Date()" compatible format
}

Every call to a ListDir method of any AFT client object will produce an array as a result; each element of such array is an object 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.

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

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

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

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