function DownloadWithPathR(what, toWhere)

The DownloadWithPathR function download the file(s) specified in the what parameter (supports wildcards) from the remote file server to the toWhere destination directory on the local file system, retaining the path of the original file and recreating it if necessary. The skip parameter is an integer number that instructs the function to skip the first N directories of the original remote path when rebuilding it into the local destination path. This function is recursive, therefore when using wildcards, this function will also download matching files from sub-directories of the directory specified in the what parameter.


 var scli = new SftpClient();
 scli.Host = '';
 scli.User = 'someusername';
 scli.KeyFile = './my_id.rsa';
 if (scli.Connect()) {
  // perform your file transfers...
  // ...
  scli.DownloadWithPathR('/arc/docs/*.docx', './here', 0); // downloads files to ./here/arc/docs and subfolders
  // ...
  scli.DownloadWithPathR('/arc/docs/*.docx', './here', 1); // skip=1 downloads files to ./here/docs and subfolders
  // ...
 scli = null