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

ISftpClient

public interface ISftpClient : IBaseClient, IDisposable
Implementation of the SSH File Transfer Protocol (SFTP) over SSH.
using Renci.SshNet.Sftp; using System; using System.Collections.Generic; using System.IO; using System.Runtime.CompilerServices; using System.Text; using System.Threading; using System.Threading.Tasks; namespace Renci.SshNet { [System.Runtime.CompilerServices.NullableContext(1)] public interface ISftpClient : IBaseClient, IDisposable { uint BufferSize { get; set; } TimeSpan OperationTimeout { get; set; } int ProtocolVersion { get; } string WorkingDirectory { get; } void AppendAllLines(string path, IEnumerable<string> contents); void AppendAllLines(string path, IEnumerable<string> contents, Encoding encoding); void AppendAllText(string path, string contents); void AppendAllText(string path, string contents, Encoding encoding); StreamWriter AppendText(string path); StreamWriter AppendText(string path, Encoding encoding); IAsyncResult BeginDownloadFile(string path, Stream output); IAsyncResult BeginDownloadFile(string path, Stream output, [System.Runtime.CompilerServices.Nullable(2)] AsyncCallback asyncCallback); IAsyncResult BeginDownloadFile(string path, Stream output, [System.Runtime.CompilerServices.Nullable(2)] AsyncCallback asyncCallback, [System.Runtime.CompilerServices.Nullable(2)] object state, [System.Runtime.CompilerServices.Nullable(2)] Action<ulong> downloadCallback = null); [System.Runtime.CompilerServices.NullableContext(2)] [return: System.Runtime.CompilerServices.Nullable(1)] IAsyncResult BeginListDirectory([System.Runtime.CompilerServices.Nullable(1)] string path, AsyncCallback asyncCallback, object state, Action<int> listCallback = null); IAsyncResult BeginSynchronizeDirectories(string sourcePath, string destinationPath, string searchPattern, [System.Runtime.CompilerServices.Nullable(2)] AsyncCallback asyncCallback, [System.Runtime.CompilerServices.Nullable(2)] object state); IAsyncResult BeginUploadFile(Stream input, string path); IAsyncResult BeginUploadFile(Stream input, string path, [System.Runtime.CompilerServices.Nullable(2)] AsyncCallback asyncCallback); IAsyncResult BeginUploadFile(Stream input, string path, [System.Runtime.CompilerServices.Nullable(2)] AsyncCallback asyncCallback, [System.Runtime.CompilerServices.Nullable(2)] object state, [System.Runtime.CompilerServices.Nullable(2)] Action<ulong> uploadCallback = null); IAsyncResult BeginUploadFile(Stream input, string path, bool canOverride, [System.Runtime.CompilerServices.Nullable(2)] AsyncCallback asyncCallback, [System.Runtime.CompilerServices.Nullable(2)] object state, [System.Runtime.CompilerServices.Nullable(2)] Action<ulong> uploadCallback = null); void ChangeDirectory(string path); void ChangePermissions(string path, short mode); SftpFileStream Create(string path); SftpFileStream Create(string path, int bufferSize); void CreateDirectory(string path); StreamWriter CreateText(string path); StreamWriter CreateText(string path, Encoding encoding); void Delete(string path); void DeleteDirectory(string path); void DeleteFile(string path); Task DeleteFileAsync(string path, CancellationToken cancellationToken); void DownloadFile(string path, Stream output, [System.Runtime.CompilerServices.Nullable(2)] Action<ulong> downloadCallback = null); void EndDownloadFile(IAsyncResult asyncResult); IEnumerable<ISftpFile> EndListDirectory(IAsyncResult asyncResult); IEnumerable<FileInfo> EndSynchronizeDirectories(IAsyncResult asyncResult); void EndUploadFile(IAsyncResult asyncResult); bool Exists(string path); ISftpFile Get(string path); SftpFileAttributes GetAttributes(string path); DateTime GetLastAccessTime(string path); DateTime GetLastAccessTimeUtc(string path); DateTime GetLastWriteTime(string path); DateTime GetLastWriteTimeUtc(string path); SftpFileSystemInformation GetStatus(string path); Task<SftpFileSystemInformation> GetStatusAsync(string path, CancellationToken cancellationToken); IEnumerable<ISftpFile> ListDirectory(string path, [System.Runtime.CompilerServices.Nullable(2)] Action<int> listCallback = null); IAsyncEnumerable<ISftpFile> ListDirectoryAsync(string path, CancellationToken cancellationToken); SftpFileStream Open(string path, FileMode mode); SftpFileStream Open(string path, FileMode mode, FileAccess access); Task<SftpFileStream> OpenAsync(string path, FileMode mode, FileAccess access, CancellationToken cancellationToken); SftpFileStream OpenRead(string path); StreamReader OpenText(string path); SftpFileStream OpenWrite(string path); byte[] ReadAllBytes(string path); string[] ReadAllLines(string path); string[] ReadAllLines(string path, Encoding encoding); string ReadAllText(string path); string ReadAllText(string path, Encoding encoding); IEnumerable<string> ReadLines(string path); IEnumerable<string> ReadLines(string path, Encoding encoding); void RenameFile(string oldPath, string newPath); void RenameFile(string oldPath, string newPath, bool isPosix); Task RenameFileAsync(string oldPath, string newPath, CancellationToken cancellationToken); void SetLastAccessTime(string path, DateTime lastAccessTime); void SetLastAccessTimeUtc(string path, DateTime lastAccessTimeUtc); void SetLastWriteTime(string path, DateTime lastWriteTime); void SetLastWriteTimeUtc(string path, DateTime lastWriteTimeUtc); void SetAttributes(string path, SftpFileAttributes fileAttributes); void SymbolicLink(string path, string linkPath); IEnumerable<FileInfo> SynchronizeDirectories(string sourcePath, string destinationPath, string searchPattern); void UploadFile(Stream input, string path, [System.Runtime.CompilerServices.Nullable(2)] Action<ulong> uploadCallback = null); void UploadFile(Stream input, string path, bool canOverride, [System.Runtime.CompilerServices.Nullable(2)] Action<ulong> uploadCallback = null); void WriteAllBytes(string path, byte[] bytes); void WriteAllLines(string path, IEnumerable<string> contents); void WriteAllLines(string path, IEnumerable<string> contents, Encoding encoding); void WriteAllLines(string path, string[] contents); void WriteAllLines(string path, string[] contents, Encoding encoding); void WriteAllText(string path, string contents); void WriteAllText(string path, string contents, Encoding encoding); } }