function DownloadWithPath(what, toWhere)

The DownloadWithPath 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 NOT recursive, therefore when using wildcards, this function will NOT download matching files from sub-directories of the directory specified in the what parameter. For a recursive version of this function see the DownloadWithPathR function.


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