<PackageReference Include="SSH.NET" Version="2020.0.2" />

ISftpClient

public interface ISftpClient
Implementation of the SSH File Transfer Protocol (SFTP) over SSH.
uint BufferSize { get; set; }

Gets or sets the maximum size of the buffer in bytes.

TimeSpan OperationTimeout { get; set; }

Gets or sets the operation timeout.

int ProtocolVersion { get; }

Gets sftp protocol version.

string WorkingDirectory { get; }

Gets remote working directory.

void AppendAllLines(string path, IEnumerable<string> contents)

Appends lines to a file, creating the file if it does not already exist.

void AppendAllLines(string path, IEnumerable<string> contents, Encoding encoding)

Appends lines to a file by using a specified encoding, creating the file if it does not already exist.

void AppendAllText(string path, string contents)

Appends the specified string to the file, creating the file if it does not already exist.

void AppendAllText(string path, string contents, Encoding encoding)

Appends the specified string to the file, creating the file if it does not already exist.

StreamWriter AppendText(string path)

Creates a StreamWriter that appends UTF-8 encoded text to the specified file, creating the file if it does not already exist.

StreamWriter AppendText(string path, Encoding encoding)

Creates a StreamWriter that appends text to a file using the specified encoding, creating the file if it does not already exist.

IAsyncResult BeginDownloadFile(string path, Stream output)

Begins an asynchronous file downloading into the stream.

IAsyncResult BeginDownloadFile(string path, Stream output, AsyncCallback asyncCallback)

Begins an asynchronous file downloading into the stream.

IAsyncResult BeginDownloadFile(string path, Stream output, AsyncCallback asyncCallback, object state, Action<ulong> downloadCallback = null)

Begins an asynchronous file downloading into the stream.

IAsyncResult BeginListDirectory(string path, AsyncCallback asyncCallback, object state, Action<int> listCallback = null)

Begins an asynchronous operation of retrieving list of files in remote directory.

IAsyncResult BeginSynchronizeDirectories(string sourcePath, string destinationPath, string searchPattern, AsyncCallback asyncCallback, object state)

Begins the synchronize directories.

IAsyncResult BeginUploadFile(Stream input, string path)

Begins an asynchronous uploading the stream into remote file.

IAsyncResult BeginUploadFile(Stream input, string path, AsyncCallback asyncCallback)

Begins an asynchronous uploading the stream into remote file.

IAsyncResult BeginUploadFile(Stream input, string path, AsyncCallback asyncCallback, object state, Action<ulong> uploadCallback = null)

Begins an asynchronous uploading the stream into remote file.

IAsyncResult BeginUploadFile(Stream input, string path, bool canOverride, AsyncCallback asyncCallback, object state, Action<ulong> uploadCallback = null)

Begins an asynchronous uploading the stream into remote file.

void ChangeDirectory(string path)

Changes remote directory to path.

void ChangePermissions(string path, short mode)

Changes permissions of file(s) to specified mode.

SftpFileStream Create(string path)

Creates or overwrites a file in the specified path.

SftpFileStream Create(string path, int bufferSize)

Creates or overwrites the specified file.

void CreateDirectory(string path)

Creates remote directory specified by path.

StreamWriter CreateText(string path)

Creates or opens a file for writing UTF-8 encoded text.

StreamWriter CreateText(string path, Encoding encoding)

Creates or opens a file for writing text using the specified encoding.

void Delete(string path)

Deletes the specified file or directory.

void DeleteDirectory(string path)

Deletes remote directory specified by path.

void DeleteFile(string path)

Deletes remote file specified by path.

void DownloadFile(string path, Stream output, Action<ulong> downloadCallback = null)

Downloads remote file specified by the path into the stream.

void EndDownloadFile(IAsyncResult asyncResult)

Ends an asynchronous file downloading into the stream.

Ends an asynchronous operation of retrieving list of files in remote directory.

Ends the synchronize directories.

void EndUploadFile(IAsyncResult asyncResult)

Ends an asynchronous uploading the stream into remote file.

bool Exists(string path)

Checks whether file or directory exists;

SftpFile Get(string path)

Gets reference to remote file or directory.

Gets the SftpFileAttributes of the file on the path.

Returns the date and time the specified file or directory was last accessed.

Returns the date and time, in coordinated universal time (UTC), that the specified file or directory was last accessed.

Returns the date and time the specified file or directory was last written to.

Returns the date and time, in coordinated universal time (UTC), that the specified file or directory was last written to.

Gets status using statvfs@openssh.com request.

IEnumerable<SftpFile> ListDirectory(string path, Action<int> listCallback = null)

Retrieves list of files in remote directory.

SftpFileStream Open(string path, FileMode mode)

Opens a SftpFileStream on the specified path with read/write access.

SftpFileStream Open(string path, FileMode mode, FileAccess access)

Opens a SftpFileStream on the specified path, with the specified mode and access.

SftpFileStream OpenRead(string path)

Opens an existing file for reading.

StreamReader OpenText(string path)

Opens an existing UTF-8 encoded text file for reading.

Opens a file for writing.

byte[] ReadAllBytes(string path)

Opens a binary file, reads the contents of the file into a byte array, and closes the file.

string[] ReadAllLines(string path)

Opens a text file, reads all lines of the file using UTF-8 encoding, and closes the file.

string[] ReadAllLines(string path, Encoding encoding)

Opens a file, reads all lines of the file with the specified encoding, and closes the file.

string ReadAllText(string path)

Opens a text file, reads all lines of the file with the UTF-8 encoding, and closes the file.

string ReadAllText(string path, Encoding encoding)

Opens a file, reads all lines of the file with the specified encoding, and closes the file.

IEnumerable<string> ReadLines(string path)

Reads the lines of a file with the UTF-8 encoding.

IEnumerable<string> ReadLines(string path, Encoding encoding)

Read the lines of a file that has a specified encoding.

void RenameFile(string oldPath, string newPath)

Renames remote file from old path to new path.

void RenameFile(string oldPath, string newPath, bool isPosix)

Renames remote file from old path to new path.

void SetAttributes(string path, SftpFileAttributes fileAttributes)

Sets the specified SftpFileAttributes of the file on the specified path.

void SymbolicLink(string path, string linkPath)

Creates a symbolic link from old path to new path.

IEnumerable<FileInfo> SynchronizeDirectories(string sourcePath, string destinationPath, string searchPattern)

Synchronizes the directories.

void UploadFile(Stream input, string path, Action<ulong> uploadCallback = null)

Uploads stream into remote file.

void UploadFile(Stream input, string path, bool canOverride, Action<ulong> uploadCallback = null)

Uploads stream into remote file.

void WriteAllBytes(string path, byte[] bytes)

Writes the specified byte array to the specified file, and closes the file.

void WriteAllLines(string path, IEnumerable<string> contents)

Writes a collection of strings to the file using the UTF-8 encoding, and closes the file.

void WriteAllLines(string path, IEnumerable<string> contents, Encoding encoding)

Writes a collection of strings to the file using the specified encoding, and closes the file.

void WriteAllLines(string path, string[] contents)

Write the specified string array to the file using the UTF-8 encoding, and closes the file.

void WriteAllLines(string path, string[] contents, Encoding encoding)

Writes the specified string array to the file by using the specified encoding, and closes the file.

void WriteAllText(string path, string contents)

Writes the specified string to the file using the UTF-8 encoding, and closes the file.

void WriteAllText(string path, string contents, Encoding encoding)

Writes the specified string to the file using the specified encoding, and closes the file.