UploadWithPath (skip paths)¶
function UploadWithPath(what, toWhere: string, skip: number): boolean
The UploadWithPath
function upload the file(s) specified in the what
parameter (supports wildcards)
to the toWhere
destination directory on the remote file server, 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 skip
directories
of the original path when rebuilding it into the destination path.
Attention
This function is not recursive, therefore when using wildcards, this function will not upload matching files from sub-directories of the directory specified in the what parameter. For a recursive version of this function see the UploadWithPathR function.
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.UploadWithPath('./data/docs/*.docx', '/archive', 0);
// ...
// skip=1 means uploads files to /archive/docs
scli.UploadWithPath('./data/docs/*.docx', '/archive', 1);
// ...
scli.Close();
}
scli = null
}