UploadWithPathR (recursive + skip paths)

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

The UploadWithPathR function upload the file(s) specified in the what parameter and all of its sub-directories (supports wildcards) to the toWhere destination directory on the remote file server, 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.

Note

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.

Example:

{
  var scli = new SftpClient();
  scli.Host = 'your.sftpserver.com:22';
  scli.User = 'someusername';
  scli.KeyFile = './my_id.rsa';
  if (scli.Connect()) {
    // uploads files to /archive/data/docs
    scli.UploadWithPathR('./data/docs/*.docx', '/archive', 0);
    // ...
    // skip=1 means uploads files to /archive/docs
    scli.UploadWithPathR('./data/docs/*.docx', '/archive', 1);
    // ...
    scli.Close();
  }
  scli = null
}