Table of Contents

Method CreateDirectoryAsync

Namespace
SshSharp.Sftp
Assembly
SshSharp.dll

CreateDirectoryAsync(string, bool, UnixFileMode?, CancellationToken)

Creates a directory; with createParents, also the directories above it that are missing, and an existing directory is not an error, as mkdir -p does. permissions, if given, apply to path itself; the parents it creates get the server's defaults (the server's umask applies to both).

public Task CreateDirectoryAsync(string path, bool createParents, UnixFileMode? permissions = null, CancellationToken cancellationToken = default)

Parameters

path string
createParents bool
permissions UnixFileMode?
cancellationToken CancellationToken

Returns

Task

Remarks

With createParents, the directory is created first, and only when that fails are the parents looked at, from path upwards, as far as the first that exists: an existing tree costs one request, and a directory above it that is not writable (a chroot's top, say) is never touched. A directory created by someone else meanwhile is accepted. A link to a directory counts as a directory.

Exceptions

SftpException

A part of the path exists and is not a directory (Failure), or the server refused to create one (for example PermissionDenied).

CreateDirectoryAsync(string, UnixFileMode?, CancellationToken)

Creates a directory, with permissions if given (the server's umask applies). To create missing parents too, and accept an existing directory, use CreateDirectoryAsync(string, bool, UnixFileMode?, CancellationToken).

public Task CreateDirectoryAsync(string path, UnixFileMode? permissions = null, CancellationToken cancellationToken = default)

Parameters

path string
permissions UnixFileMode?
cancellationToken CancellationToken

Returns

Task

Exceptions

SftpException

It exists already, the parent does not exist, or another error.