Method DownloadDirectoryAsync
DownloadDirectoryAsync(string, string, SftpTransferOptions?, CancellationToken)
Downloads the directory remoteDirectory and everything under it into localDirectory (created
if needed), file by file with DownloadFileAsync(string, string, SftpTransferOptions?, CancellationToken) and the same options. Symbolic links and special
files are skipped, so a link cannot lead the download outside the tree.
public Task<SftpTransferSummary> DownloadDirectoryAsync(string remoteDirectory, string localDirectory, SftpTransferOptions? options = null, CancellationToken cancellationToken = default)
Parameters
remoteDirectorystringlocalDirectorystringoptionsSftpTransferOptionscancellationTokenCancellationToken
Returns
Remarks
Every name the server lists is checked before it becomes a local path: names that cannot be a file name on this system (a
separator, . or .., control characters, a name that is not valid UTF-8; on Windows also </code>, :, device
names such as CON or NUL, and trailing dots) are skipped and counted in Skipped, and
the resulting path must stay inside localDirectory.
Exceptions
- SshException
A path would end up outside the target (TransferFailed), or the tree is deeper than 64 levels.