Interface ISftpDirectory
Interface for SFTP directory operations.
public interface ISftpDirectory
- Extension Methods
Properties
Path
Gets the directory path.
string Path { get; }
Property Value
Methods
CopyFileAsync(string, string, bool, CancellationToken)
Copies a file.
ValueTask CopyFileAsync(string sourcePath, string destinationPath, bool overwrite = false, CancellationToken cancellationToken = default)
Parameters
sourcePathstringThe source file path.
destinationPathstringThe destination file path.
overwriteboolWhether to overwrite an existing file.
cancellationTokenCancellationTokenToken to cancel the operation.
Returns
CreateDirectoryAsync(string, bool, UnixFilePermissions, CancellationToken)
Creates a directory. This does not fail when the directory exists (or is a link to a directory).
ValueTask CreateDirectoryAsync(string path, bool createParents = false, UnixFilePermissions permissions = UnixFilePermissions.OtherExecute | UnixFilePermissions.OtherWrite | UnixFilePermissions.OtherRead | UnixFilePermissions.GroupExecute | UnixFilePermissions.GroupWrite | UnixFilePermissions.GroupRead | UnixFilePermissions.UserExecute | UnixFilePermissions.UserWrite | UnixFilePermissions.UserRead, CancellationToken cancellationToken = default)
Parameters
pathstringThe directory path.
createParentsboolWhether to create parent directories.
permissionsUnixFilePermissionsUnixFilePermissions used when a new directory is created.
cancellationTokenCancellationTokenToken to cancel the operation.
Returns
CreateNewDirectoryAsync(string, bool, UnixFilePermissions, CancellationToken)
Creates a new directory. This fails when the directory already exists.
ValueTask CreateNewDirectoryAsync(string path, bool createParents = false, UnixFilePermissions permissions = UnixFilePermissions.OtherExecute | UnixFilePermissions.OtherWrite | UnixFilePermissions.OtherRead | UnixFilePermissions.GroupExecute | UnixFilePermissions.GroupWrite | UnixFilePermissions.GroupRead | UnixFilePermissions.UserExecute | UnixFilePermissions.UserWrite | UnixFilePermissions.UserRead, CancellationToken cancellationToken = default)
Parameters
pathstringThe directory path.
createParentsboolWhether to create parent directories.
permissionsUnixFilePermissionsUnixFilePermissions for the new directory.
cancellationTokenCancellationTokenToken to cancel the operation.
Returns
CreateNewFileAsync(string, FileAccess, FileOpenOptions?, CancellationToken)
Creates a new file. Fails if it already exists.
ValueTask<SftpFile> CreateNewFileAsync(string path, FileAccess access, FileOpenOptions? options, CancellationToken cancellationToken = default)
Parameters
pathstringThe file path.
accessFileAccessThe FileAccess mode.
optionsFileOpenOptionsFileOpenOptions for creating the file.
cancellationTokenCancellationTokenToken to cancel the operation.
Returns
CreateSymbolicLinkAsync(string, string, CancellationToken)
Creates a symbolic link.
ValueTask CreateSymbolicLinkAsync(string linkPath, string targetPath, CancellationToken cancellationToken = default)
Parameters
linkPathstringThe symbolic link path to create.
targetPathstringThe target path the link points to.
cancellationTokenCancellationTokenToken to cancel the operation.
Returns
DeleteDirectoryAsync(string, bool, CancellationToken)
Deletes a directory. This does not fail when the directory does not exist.
ValueTask DeleteDirectoryAsync(string path, bool recursive = false, CancellationToken cancellationToken = default)
Parameters
pathstringThe directory path.
recursiveboolWhether to delete directories recursively.
cancellationTokenCancellationTokenToken to cancel the operation.
Returns
DeleteFileAsync(string, CancellationToken)
Deletes a file. This does not fail when the file does not exist.
ValueTask DeleteFileAsync(string path, CancellationToken cancellationToken = default)
Parameters
pathstringThe file path.
cancellationTokenCancellationTokenToken to cancel the operation.
Returns
DownloadDirectoryEntriesAsync(string, string, DownloadEntriesOptions?, CancellationToken)
Downloads directory entries.
ValueTask DownloadDirectoryEntriesAsync(string remoteDirPath, string localDirPath, DownloadEntriesOptions? options, CancellationToken cancellationToken = default)
Parameters
remoteDirPathstringThe remote directory path.
localDirPathstringThe local directory path.
optionsDownloadEntriesOptionsDownloadEntriesOptions for the download operation.
cancellationTokenCancellationTokenToken to cancel the operation.
Returns
DownloadFileAsync(string, Stream, CancellationToken)
Downloads a file to a Stream.
ValueTask DownloadFileAsync(string remoteFilePath, Stream destination, CancellationToken cancellationToken = default)
Parameters
remoteFilePathstringThe remote file path.
destinationStreamThe destination Stream.
cancellationTokenCancellationTokenToken to cancel the operation.
Returns
DownloadFileAsync(string, string, bool, CancellationToken)
Downloads a file.
ValueTask DownloadFileAsync(string remoteFilePath, string localFilePath, bool overwrite = false, CancellationToken cancellationToken = default)
Parameters
remoteFilePathstringThe remote file path.
localFilePathstringThe local file path.
overwriteboolWhether to overwrite an existing file.
cancellationTokenCancellationTokenToken to cancel the operation.
Returns
GetAttributesAsync(string, bool, string[]?, CancellationToken)
Gets file or directory attributes.
ValueTask<FileEntryAttributes?> GetAttributesAsync(string path, bool followLinks, string[]? filter, CancellationToken cancellationToken = default)
Parameters
pathstringThe file or directory path.
followLinksboolWhether to follow symbolic links.
filterstring[]Extended attributes to include. Set to null to include all.
cancellationTokenCancellationTokenToken to cancel the operation.
Returns
- ValueTask<FileEntryAttributes>
The FileEntryAttributes, or null if not found.
GetDirectory(string)
Gets an SftpDirectory for the specified path.
ISftpDirectory GetDirectory(string path)
Parameters
pathstringThe directory path.
Returns
- ISftpDirectory
An ISftpDirectory for the specified path.
GetDirectoryEntriesAsync<T>(string, SftpFileEntryTransform<T>, EnumerationOptions?)
Enumerates directory entries asynchronously.
IAsyncEnumerable<T> GetDirectoryEntriesAsync<T>(string path, SftpFileEntryTransform<T> transform, EnumerationOptions? options = null)
Parameters
pathstringThe directory path to enumerate.
transformSftpFileEntryTransform<T>SftpFileEntryTransform<T> function for each entry.
optionsEnumerationOptionsEnumerationOptions for enumeration.
Returns
- IAsyncEnumerable<T>
An async enumerable of transformed entries.
Type Parameters
TResult type to transform entries to.
GetLinkTargetAsync(string, CancellationToken)
Gets the target of a symbolic link.
ValueTask<string> GetLinkTargetAsync(string linkPath, CancellationToken cancellationToken = default)
Parameters
linkPathstringThe symbolic link path.
cancellationTokenCancellationTokenToken to cancel the operation.
Returns
GetRealPathAsync(string, CancellationToken)
Resolves a path to its canonical absolute path.
ValueTask<string> GetRealPathAsync(string path, CancellationToken cancellationToken = default)
Parameters
pathstringThe path to resolve.
cancellationTokenCancellationTokenToken to cancel the operation.
Returns
OpenFileAsync(string, FileAccess, FileOpenOptions?, CancellationToken)
Opens an existing file.
ValueTask<SftpFile?> OpenFileAsync(string path, FileAccess access, FileOpenOptions? options, CancellationToken cancellationToken = default)
Parameters
pathstringThe file path.
accessFileAccessThe FileAccess mode.
optionsFileOpenOptionsFileOpenOptions for opening the file.
cancellationTokenCancellationTokenToken to cancel the operation.
Returns
OpenOrCreateFileAsync(string, FileAccess, FileOpenOptions?, CancellationToken)
Opens an existing file or creates it when it does not yet exist.
ValueTask<SftpFile> OpenOrCreateFileAsync(string path, FileAccess access, FileOpenOptions? options, CancellationToken cancellationToken = default)
Parameters
pathstringThe file path.
accessFileAccessThe FileAccess mode.
optionsFileOpenOptionsFileOpenOptions for opening the file.
cancellationTokenCancellationTokenToken to cancel the operation.
Returns
RenameAsync(string, string, CancellationToken)
Renames or moves a file or directory.
ValueTask RenameAsync(string oldPath, string newPath, CancellationToken cancellationToken = default)
Parameters
oldPathstringThe current path.
newPathstringThe new path.
cancellationTokenCancellationTokenToken to cancel the operation.
Returns
SetAttributesAsync(string, UnixFilePermissions?, (DateTimeOffset LastAccess, DateTimeOffset LastWrite)?, long?, (int Uid, int Gid)?, IEnumerable<KeyValuePair<string, Memory<byte>>>?, CancellationToken)
Sets file or directory attributes.
ValueTask SetAttributesAsync(string path, UnixFilePermissions? permissions = null, (DateTimeOffset LastAccess, DateTimeOffset LastWrite)? times = null, long? length = null, (int Uid, int Gid)? ids = null, IEnumerable<KeyValuePair<string, Memory<byte>>>? extendedAttributes = null, CancellationToken cancellationToken = default)
Parameters
pathstringThe file or directory path.
permissionsUnixFilePermissions?UnixFilePermissions to set.
times(DateTimeOffset LastAccess, DateTimeOffset LastWrite)?Access and modification times to set.
lengthlong?File length to set (truncates or extends).
ids(int Uid, int Gid)?User and group IDs to set.
extendedAttributesIEnumerable<KeyValuePair<string, Memory<byte>>>Extended attributes to set.
cancellationTokenCancellationTokenToken to cancel the operation.
Returns
UploadDirectoryEntriesAsync(string, string, UploadEntriesOptions?, CancellationToken)
Uploads directory entries.
ValueTask UploadDirectoryEntriesAsync(string localDirPath, string remoteDirPath, UploadEntriesOptions? options, CancellationToken cancellationToken = default)
Parameters
localDirPathstringThe local directory path.
remoteDirPathstringThe remote directory path.
optionsUploadEntriesOptionsUploadEntriesOptions for the upload operation.
cancellationTokenCancellationTokenToken to cancel the operation.
Returns
UploadFileAsync(Stream, string, bool, UnixFilePermissions, CancellationToken)
Uploads a file from a Stream.
ValueTask UploadFileAsync(Stream source, string remoteFilePath, bool overwrite = false, UnixFilePermissions createPermissions = UnixFilePermissions.OtherWrite | UnixFilePermissions.OtherRead | UnixFilePermissions.GroupWrite | UnixFilePermissions.GroupRead | UnixFilePermissions.UserWrite | UnixFilePermissions.UserRead, CancellationToken cancellationToken = default)
Parameters
sourceStreamThe source Stream.
remoteFilePathstringThe remote file path.
overwriteboolWhether to overwrite an existing file.
createPermissionsUnixFilePermissionsUnixFilePermissions when a new file is created.
cancellationTokenCancellationTokenToken to cancel the operation.
Returns
UploadFileAsync(string, string, bool, UnixFilePermissions?, CancellationToken)
Uploads a file.
ValueTask UploadFileAsync(string localFilePath, string remoteFilePath, bool overwrite = false, UnixFilePermissions? createPermissions = null, CancellationToken cancellationToken = default)
Parameters
localFilePathstringThe local file path.
remoteFilePathstringThe remote file path.
overwriteboolWhether to overwrite an existing file.
createPermissionsUnixFilePermissions?UnixFilePermissions when a new file is created.
cancellationTokenCancellationTokenToken to cancel the operation.