|
@@ -373,6 +373,32 @@ namespace Renci.SshNet
|
|
|
_sftpSession.RequestMkDir(fullPath);
|
|
_sftpSession.RequestMkDir(fullPath);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /// <summary>
|
|
|
|
|
+ /// Asynchronously requests to create a remote directory specified by path.
|
|
|
|
|
+ /// </summary>
|
|
|
|
|
+ /// <param name="path">Directory path to create.</param>
|
|
|
|
|
+ /// <param name="cancellationToken">The <see cref="CancellationToken"/> to observe.</param>
|
|
|
|
|
+ /// <returns>A <see cref="Task"/> that represents the asynchronous create directory operation.</returns>
|
|
|
|
|
+ /// <exception cref="ArgumentException"><paramref name="path"/> is <see langword="null"/> or contains only whitespace characters.</exception>
|
|
|
|
|
+ /// <exception cref="SshConnectionException">Client is not connected.</exception>
|
|
|
|
|
+ /// <exception cref="SftpPermissionDeniedException">Permission to create the directory was denied by the remote host. <para>-or-</para> A SSH command was denied by the server.</exception>
|
|
|
|
|
+ /// <exception cref="SshException">A SSH error where <see cref="Exception.Message"/> is the message from the remote host.</exception>
|
|
|
|
|
+ /// <exception cref="ObjectDisposedException">The method was called after the client was disposed.</exception>
|
|
|
|
|
+ public async Task CreateDirectoryAsync(string path, CancellationToken cancellationToken = default)
|
|
|
|
|
+ {
|
|
|
|
|
+ CheckDisposed();
|
|
|
|
|
+ ThrowHelper.ThrowIfNullOrWhiteSpace(path);
|
|
|
|
|
+
|
|
|
|
|
+ if (_sftpSession is null)
|
|
|
|
|
+ {
|
|
|
|
|
+ throw new SshConnectionException("Client not connected.");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ var fullPath = await _sftpSession.GetCanonicalPathAsync(path, cancellationToken).ConfigureAwait(false);
|
|
|
|
|
+
|
|
|
|
|
+ await _sftpSession.RequestMkDirAsync(fullPath, cancellationToken).ConfigureAwait(false);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/// <summary>
|
|
/// <summary>
|
|
|
/// Deletes remote directory specified by path.
|
|
/// Deletes remote directory specified by path.
|
|
|
/// </summary>
|
|
/// </summary>
|