DownloadWithPath (skip paths)¶
function DownloadWithPath(what, toWhere: string, skip: number): boolean
The DownloadWithPath
function download the file(s) specified in the what
parameter (supports wildcards)
to the toWhere
destination directory on the local computer, 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 DownloadWithPathR function.
Example:
{
var scli = new SftpClient();
scli.Host = 'your.sftpserver.com:22';
scli.User = 'someusername';
scli.KeyFile = './my_id.rsa';
if (scli.Connect()) {
// downloads files to /archive/data/docs
scli.DownloadWithPath('./data/docs/*.docx', '/archive', 0);
// ...
// skip=1 means downloads files to /archive/docs
scli.DownloadWithPath('./data/docs/*.docx', '/archive', 1);
// ...
scli.Close();
}
scli = null
}