DownloadWithPathR (recursive + skip paths)

function DownloadWithPathR(what, toWhere: string, skip: number): boolean

The DownloadWithPathR function download the file(s) specified in the what parameter and all of its sub-directories (supports wildcards) to the toWhere destination directory on the local computer, retaining the paths of the original files and recreating the entire directory tree when necessary.

The skip parameter is an integer number that instructs the function to skip the first skip directories of the original path when rebuilding it into the destination path.


This function is recursive, therefore when using wildcards, this function will upload matching files from all sub-directories of the directory specified in the what parameter. In doing so, it will also create all necessary directories and sub-directories on the remote side.


  var scli = new SftpClient();
  scli.Host = '';
  scli.User = 'someusername';
  scli.KeyFile = './my_id.rsa';
  if (scli.Connect()) {
    // downloads files to /archive/data/docs
    scli.DownloadWithPathR('./data/docs/*.docx', '/archive', 0);
    // ...
    // skip=1 means downloads files to /archive/docs
    scli.DownloadWithPathR('./data/docs/*.docx', '/archive', 1);
    // ...
  scli = null