using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Renci.SshNet.Common;
using Renci.SshNet.Sftp;
namespace Renci.SshNet
{
///
/// Implementation of the SSH File Transfer Protocol (SFTP) over SSH.
///
public interface ISftpClient : IBaseClient, IDisposable
{
///
/// Gets or sets the maximum size of the buffer in bytes.
///
///
/// The size of the buffer. The default buffer size is 32768 bytes (32 KB).
///
///
///
/// For write operations, this limits the size of the payload for
/// individual SSH_FXP_WRITE messages. The actual size is always
/// capped at the maximum packet size supported by the peer
/// (minus the size of protocol fields).
///
///
/// For read operations, this controls the size of the payload which
/// is requested from the peer in a SSH_FXP_READ message. The peer
/// will send the requested number of bytes in a SSH_FXP_DATA message,
/// possibly split over multiple SSH_MSG_CHANNEL_DATA messages.
///
///
/// To optimize the size of the SSH packets sent by the peer,
/// the actual requested size will take into account the size of the
/// SSH_FXP_DATA protocol fields.
///
///
/// The size of the each individual SSH_FXP_DATA message is limited to the
/// local maximum packet size of the channel, which is set to 64 KB
/// for SSH.NET. However, the peer can limit this even further.
///
///
/// The method was called after the client was disposed.
uint BufferSize { get; set; }
///
/// Gets or sets the operation timeout.
///
///
/// The timeout to wait until an operation completes. The default value is negative
/// one (-1) milliseconds, which indicates an infinite timeout period.
///
/// The method was called after the client was disposed.
/// represents a value that is less than -1 or greater than milliseconds.
TimeSpan OperationTimeout { get; set; }
///
/// Gets sftp protocol version.
///
/// Client is not connected.
/// The method was called after the client was disposed.
int ProtocolVersion { get; }
///
/// Gets remote working directory.
///
/// Client is not connected.
/// The method was called after the client was disposed.
string WorkingDirectory { get; }
///
/// Appends lines to a file, creating the file if it does not already exist.
///
/// The file to append the lines to. The file is created if it does not already exist.
/// The lines to append to the file.
/// isnull -or- is null.
/// Client is not connected.
/// The specified path is invalid, or its directory was not found on the remote host.
/// The method was called after the client was disposed.
///
/// The characters are written to the file using UTF-8 encoding without a Byte-Order Mark (BOM)
///
void AppendAllLines(string path, IEnumerable contents);
///
/// Appends lines to a file by using a specified encoding, creating the file if it does not already exist.
///
/// The file to append the lines to. The file is created if it does not already exist.
/// The lines to append to the file.
/// The character encoding to use.
/// is null. -or- is null. -or- is null.
/// Client is not connected.
/// The specified path is invalid, or its directory was not found on the remote host.
/// The method was called after the client was disposed.
void AppendAllLines(string path, IEnumerable contents, Encoding encoding);
///
/// Appends the specified string to the file, creating the file if it does not already exist.
///
/// The file to append the specified string to.
/// The string to append to the file.
/// is null. -or- is null.
/// Client is not connected.
/// The specified path is invalid, or its directory was not found on the remote host.
/// The method was called after the client was disposed.
///
/// The characters are written to the file using UTF-8 encoding without a Byte-Order Mark (BOM).
///
void AppendAllText(string path, string contents);
///
/// Appends the specified string to the file, creating the file if it does not already exist.
///
/// The file to append the specified string to.
/// The string to append to the file.
/// The character encoding to use.
/// is null. -or- is null. -or- is null.
/// Client is not connected.
/// The specified path is invalid, or its directory was not found on the remote host.
/// The method was called after the client was disposed.
void AppendAllText(string path, string contents, Encoding encoding);
///
/// Creates a that appends UTF-8 encoded text to the specified file,
/// creating the file if it does not already exist.
///
/// The path to the file to append to.
///
/// A that appends text to a file using UTF-8 encoding without a
/// Byte-Order Mark (BOM).
///
/// is null.
/// Client is not connected.
/// The specified path is invalid, or its directory was not found on the remote host.
/// The method was called after the client was disposed.
StreamWriter AppendText(string path);
///
/// Creates a that appends text to a file using the specified
/// encoding, creating the file if it does not already exist.
///
/// The path to the file to append to.
/// The character encoding to use.
///
/// A that appends text to a file using the specified encoding.
///
/// is null. -or- is null.
/// Client is not connected.
/// The specified path is invalid, or its directory was not found on the remote host.
/// The method was called after the client was disposed.
StreamWriter AppendText(string path, Encoding encoding);
///
/// Begins an asynchronous file downloading into the stream.
///
/// The path.
/// The output.
///
/// An that references the asynchronous operation.
///
/// is null.
/// is null or contains only whitespace characters.
/// Client is not connected.
/// Permission to perform the operation was denied by the remote host. -or- A SSH command was denied by the server.
/// A SSH error where is the message from the remote host.
/// The method was called after the client was disposed.
///
/// Method calls made by this method to , may under certain conditions result in exceptions thrown by the stream.
///
IAsyncResult BeginDownloadFile(string path, Stream output);
///
/// Begins an asynchronous file downloading into the stream.
///
/// The path.
/// The output.
/// The method to be called when the asynchronous write operation is completed.
///
/// An that references the asynchronous operation.
///
/// is null.
/// is null or contains only whitespace characters.
/// Client is not connected.
/// Permission to perform the operation was denied by the remote host. -or- A SSH command was denied by the server.
/// A SSH error where is the message from the remote host.
/// The method was called after the client was disposed.
///
/// Method calls made by this method to , may under certain conditions result in exceptions thrown by the stream.
///
IAsyncResult BeginDownloadFile(string path, Stream output, AsyncCallback asyncCallback);
///
/// Begins an asynchronous file downloading into the stream.
///
/// The path.
/// The output.
/// The method to be called when the asynchronous write operation is completed.
/// A user-provided object that distinguishes this particular asynchronous write request from other requests.
/// The download callback.
///
/// An that references the asynchronous operation.
///
/// is null.
/// is null or contains only whitespace characters.
/// The method was called after the client was disposed.
///
/// Method calls made by this method to , may under certain conditions result in exceptions thrown by the stream.
///
IAsyncResult BeginDownloadFile(string path, Stream output, AsyncCallback asyncCallback, object state, Action downloadCallback = null);
///
/// Begins an asynchronous operation of retrieving list of files in remote directory.
///
/// The path.
/// The method to be called when the asynchronous write operation is completed.
/// A user-provided object that distinguishes this particular asynchronous write request from other requests.
/// The list callback.
///
/// An that references the asynchronous operation.
///
/// The method was called after the client was disposed.
IAsyncResult BeginListDirectory(string path, AsyncCallback asyncCallback, object state, Action listCallback = null);
///
/// Begins the synchronize directories.
///
/// The source path.
/// The destination path.
/// The search pattern.
/// The async callback.
/// The state.
///
/// An that represents the asynchronous directory synchronization.
///
/// is null.
/// is null or contains only whitespace.
IAsyncResult BeginSynchronizeDirectories(string sourcePath, string destinationPath, string searchPattern, AsyncCallback asyncCallback, object state);
///
/// Begins an asynchronous uploading the stream into remote file.
///
/// Data input stream.
/// Remote file path.
///
/// An that references the asynchronous operation.
///
/// is null.
/// is null or contains only whitespace characters.
/// Client is not connected.
/// Permission to list the contents of the directory was denied by the remote host. -or- A SSH command was denied by the server.
/// A SSH error where is the message from the remote host.
/// The method was called after the client was disposed.
///
///
/// Method calls made by this method to , may under certain conditions result in exceptions thrown by the stream.
///
///
/// If the remote file already exists, it is overwritten and truncated.
///
///
IAsyncResult BeginUploadFile(Stream input, string path);
///
/// Begins an asynchronous uploading the stream into remote file.
///
/// Data input stream.
/// Remote file path.
/// The method to be called when the asynchronous write operation is completed.
///
/// An that references the asynchronous operation.
///
/// is null.
/// is null or contains only whitespace characters.
/// Client is not connected.
/// Permission to list the contents of the directory was denied by the remote host. -or- A SSH command was denied by the server.
/// A SSH error where is the message from the remote host.
/// The method was called after the client was disposed.
///
///
/// Method calls made by this method to , may under certain conditions result in exceptions thrown by the stream.
///
///
/// If the remote file already exists, it is overwritten and truncated.
///
///
IAsyncResult BeginUploadFile(Stream input, string path, AsyncCallback asyncCallback);
///
/// Begins an asynchronous uploading the stream into remote file.
///
/// Data input stream.
/// Remote file path.
/// The method to be called when the asynchronous write operation is completed.
/// A user-provided object that distinguishes this particular asynchronous write request from other requests.
/// The upload callback.
///
/// An that references the asynchronous operation.
///
/// is null.
/// is null or contains only whitespace characters.
/// Client is not connected.
/// Permission to list the contents of the directory was denied by the remote host. -or- A SSH command was denied by the server.
/// A SSH error where is the message from the remote host.
/// The method was called after the client was disposed.
///
///
/// Method calls made by this method to , may under certain conditions result in exceptions thrown by the stream.
///
///
/// If the remote file already exists, it is overwritten and truncated.
///
///
IAsyncResult BeginUploadFile(Stream input, string path, AsyncCallback asyncCallback, object state, Action uploadCallback = null);
///
/// Begins an asynchronous uploading the stream into remote file.
///
/// Data input stream.
/// Remote file path.
/// Specified whether an existing file can be overwritten.
/// The method to be called when the asynchronous write operation is completed.
/// A user-provided object that distinguishes this particular asynchronous write request from other requests.
/// The upload callback.
///
/// An that references the asynchronous operation.
///
/// is null.
/// is null or contains only whitespace characters.
/// The method was called after the client was disposed.
///
///
/// Method calls made by this method to , may under certain conditions result in exceptions thrown by the stream.
///
///
/// When refers to an existing file, set to true to overwrite and truncate that file.
/// If is false, the upload will fail and will throw an
/// .
///
///
IAsyncResult BeginUploadFile(Stream input, string path, bool canOverride, AsyncCallback asyncCallback, object state, Action uploadCallback = null);
///
/// Changes remote directory to path.
///
/// New directory path.
/// is null.
/// Client is not connected.
/// Permission to change directory denied by remote host. -or- A SSH command was denied by the server.
/// was not found on the remote host.
/// A SSH error where is the message from the remote host.
/// The method was called after the client was disposed.
void ChangeDirectory(string path);
///
/// Changes permissions of file(s) to specified mode.
///
/// File(s) path, may match multiple files.
/// The mode.
/// is null.
/// Client is not connected.
/// Permission to change permission on the path(s) was denied by the remote host. -or- A SSH command was denied by the server.
/// was not found on the remote host.
/// A SSH error where is the message from the remote host.
/// The method was called after the client was disposed.
void ChangePermissions(string path, short mode);
///
/// Creates or overwrites a file in the specified path.
///
/// The path and name of the file to create.
///
/// A that provides read/write access to the file specified in path.
///
/// is null.
/// Client is not connected.
/// The specified path is invalid, or its directory was not found on the remote host.
/// The method was called after the client was disposed.
///
/// If the target file already exists, it is first truncated to zero bytes.
///
SftpFileStream Create(string path);
///
/// Creates or overwrites the specified file.
///
/// The path and name of the file to create.
/// The maximum number of bytes buffered for reads and writes to the file.
///
/// A that provides read/write access to the file specified in path.
///
/// is null.
/// Client is not connected.
/// The specified path is invalid, or its directory was not found on the remote host.
/// The method was called after the client was disposed.
///
/// If the target file already exists, it is first truncated to zero bytes.
///
SftpFileStream Create(string path, int bufferSize);
///
/// Creates remote directory specified by path.
///
/// Directory path to create.
/// is null or contains only whitespace characters.
/// Client is not connected.
/// Permission to create the directory was denied by the remote host. -or- A SSH command was denied by the server.
/// A SSH error where is the message from the remote host.
/// The method was called after the client was disposed.
void CreateDirectory(string path);
///
/// Creates or opens a file for writing UTF-8 encoded text.
///
/// The file to be opened for writing.
///
/// A that writes text to a file using UTF-8 encoding without
/// a Byte-Order Mark (BOM).
///
/// is null.
/// Client is not connected.
/// The specified path is invalid, or its directory was not found on the remote host.
/// The method was called after the client was disposed.
///
///
/// If the target file already exists, it is overwritten. It is not first truncated to zero bytes.
///
///
/// If the target file does not exist, it is created.
///
///
StreamWriter CreateText(string path);
///
/// Creates or opens a file for writing text using the specified encoding.
///
/// The file to be opened for writing.
/// The character encoding to use.
///
/// A that writes to a file using the specified encoding.
///
/// is null.
/// Client is not connected.
/// The specified path is invalid, or its directory was not found on the remote host.
/// The method was called after the client was disposed.
///
///
/// If the target file already exists, it is overwritten. It is not first truncated to zero bytes.
///
///
/// If the target file does not exist, it is created.
///
///
StreamWriter CreateText(string path, Encoding encoding);
///
/// Deletes the specified file or directory.
///
/// The name of the file or directory to be deleted. Wildcard characters are not supported.
/// is null.
/// Client is not connected.
/// was not found on the remote host.
/// The method was called after the client was disposed.
void Delete(string path);
///
/// Deletes remote directory specified by path.
///
/// Directory to be deleted path.
/// is null or contains only whitespace characters.
/// Client is not connected.
/// was not found on the remote host.
/// Permission to delete the directory was denied by the remote host. -or- A SSH command was denied by the server.
/// A SSH error where is the message from the remote host.
/// The method was called after the client was disposed.
void DeleteDirectory(string path);
///
/// Deletes remote file specified by path.
///
/// File to be deleted path.
/// is null or contains only whitespace characters.
/// Client is not connected.
/// was not found on the remote host.
/// Permission to delete the file was denied by the remote host. -or- A SSH command was denied by the server.
/// A SSH error where is the message from the remote host.
/// The method was called after the client was disposed.
void DeleteFile(string path);
///
/// Asynchronously deletes remote file specified by path.
///
/// File to be deleted path.
/// The to observe.
/// A that represents the asynchronous delete operation.
/// is null or contains only whitespace characters.
/// Client is not connected.
/// was not found on the remote host.
/// Permission to delete the file was denied by the remote host. -or- A SSH command was denied by the server.
/// A SSH error where is the message from the remote host.
/// The method was called after the client was disposed.
Task DeleteFileAsync(string path, CancellationToken cancellationToken);
///
/// Downloads remote file specified by the path into the stream.
///
/// File to download.
/// Stream to write the file into.
/// The download callback.
/// is null.
/// is null or contains only whitespace characters.
/// Client is not connected.
/// Permission to perform the operation was denied by the remote host. -or- A SSH command was denied by the server.
/// was not found on the remote host.///
/// A SSH error where is the message from the remote host.
/// The method was called after the client was disposed.
///
/// Method calls made by this method to , may under certain conditions result in exceptions thrown by the stream.
///
void DownloadFile(string path, Stream output, Action downloadCallback = null);
///
/// Ends an asynchronous file downloading into the stream.
///
/// The pending asynchronous SFTP request.
/// The object did not come from the corresponding async method on this type.-or- was called multiple times with the same .
/// Client is not connected.
/// Permission to perform the operation was denied by the remote host. -or- A SSH command was denied by the server.
/// The path was not found on the remote host.
/// A SSH error where is the message from the remote host.
void EndDownloadFile(IAsyncResult asyncResult);
///
/// Ends an asynchronous operation of retrieving list of files in remote directory.
///
/// The pending asynchronous SFTP request.
///
/// A list of files.
///
/// The object did not come from the corresponding async method on this type.-or- was called multiple times with the same .
IEnumerable EndListDirectory(IAsyncResult asyncResult);
///
/// Ends the synchronize directories.
///
/// The async result.
///
/// A list of uploaded files.
///
/// The object did not come from the corresponding async method on this type.-or- was called multiple times with the same .
/// The destination path was not found on the remote host.
IEnumerable EndSynchronizeDirectories(IAsyncResult asyncResult);
///
/// Ends an asynchronous uploading the stream into remote file.
///
/// The pending asynchronous SFTP request.
/// The object did not come from the corresponding async method on this type.-or- was called multiple times with the same .
/// Client is not connected.
/// The directory of the file was not found on the remote host.
/// Permission to upload the file was denied by the remote host. -or- A SSH command was denied by the server.
/// A SSH error where is the message from the remote host.
void EndUploadFile(IAsyncResult asyncResult);
///
/// Checks whether file or directory exists;
///
/// The path.
///
/// true if directory or file exists; otherwise false.
///
/// is null or contains only whitespace characters.
/// Client is not connected.
/// Permission to perform the operation was denied by the remote host. -or- A SSH command was denied by the server.
/// A SSH error where is the message from the remote host.
/// The method was called after the client was disposed.
bool Exists(string path);
///
/// Gets reference to remote file or directory.
///
/// The path.
///
/// A reference to file object.
///
/// Client is not connected.
/// was not found on the remote host.
/// is null.
/// The method was called after the client was disposed.
ISftpFile Get(string path);
///
/// Gets the of the file on the path.
///
/// The path to the file.
///
/// The of the file on the path.
///
/// is null.
/// Client is not connected.
/// was not found on the remote host.
/// The method was called after the client was disposed.
SftpFileAttributes GetAttributes(string path);
///
/// Returns the date and time the specified file or directory was last accessed.
///
/// The file or directory for which to obtain access date and time information.
///
/// A structure set to the date and time that the specified file or directory was last accessed.
/// This value is expressed in local time.
///
/// is null.
/// Client is not connected.
/// The method was called after the client was disposed.
DateTime GetLastAccessTime(string path);
///
/// Returns the date and time, in coordinated universal time (UTC), that the specified file or directory was last accessed.
///
/// The file or directory for which to obtain access date and time information.
///
/// A structure set to the date and time that the specified file or directory was last accessed.
/// This value is expressed in UTC time.
///
/// is null.
/// Client is not connected.
/// The method was called after the client was disposed.
DateTime GetLastAccessTimeUtc(string path);
///
/// Returns the date and time the specified file or directory was last written to.
///
/// The file or directory for which to obtain write date and time information.
///
/// A structure set to the date and time that the specified file or directory was last written to.
/// This value is expressed in local time.
///
/// is null.
/// Client is not connected.
/// The method was called after the client was disposed.
DateTime GetLastWriteTime(string path);
///
/// Returns the date and time, in coordinated universal time (UTC), that the specified file or directory was last written to.
///
/// The file or directory for which to obtain write date and time information.
///
/// A structure set to the date and time that the specified file or directory was last written to.
/// This value is expressed in UTC time.
///
/// is null.
/// Client is not connected.
/// The method was called after the client was disposed.
DateTime GetLastWriteTimeUtc(string path);
///
/// Gets status using statvfs@openssh.com request.
///
/// The path.
///
/// A instance that contains file status information.
///
/// Client is not connected.
/// is null.
/// The method was called after the client was disposed.
SftpFileSytemInformation GetStatus(string path);
///
/// Asynchronously gets status using statvfs@openssh.com request.
///
/// The path.
/// The to observe.
///
/// A that represents the status operation.
/// The task result contains the instance that contains file status information.
///
/// Client is not connected.
/// is null.
/// The method was called after the client was disposed.
Task GetStatusAsync(string path, CancellationToken cancellationToken);
///
/// Retrieves list of files in remote directory.
///
/// The path.
/// The list callback.
///
/// A list of files.
///
/// is null.
/// Client is not connected.
/// Permission to list the contents of the directory was denied by the remote host. -or- A SSH command was denied by the server.
/// A SSH error where is the message from the remote host.
/// The method was called after the client was disposed.
IEnumerable ListDirectory(string path, Action listCallback = null);
#if FEATURE_ASYNC_ENUMERABLE
///
/// Asynchronously enumerates the files in remote directory.
///
/// The path.
/// The to observe.
///
/// An of that represents the asynchronous enumeration operation.
/// The enumeration contains an async stream of for the files in the directory specified by .
///
/// is null.
/// Client is not connected.
/// Permission to list the contents of the directory was denied by the remote host. -or- A SSH command was denied by the server.
/// A SSH error where is the message from the remote host.
/// The method was called after the client was disposed.
IAsyncEnumerable ListDirectoryAsync(string path, CancellationToken cancellationToken);
#endif //FEATURE_ASYNC_ENUMERABLE
///
/// Opens a on the specified path with read/write access.
///
/// The file to open.
/// A value that specifies whether a file is created if one does not exist, and determines whether the contents of existing files are retained or overwritten.
///
/// An unshared that provides access to the specified file, with the specified mode and read/write access.
///
/// is null.
/// Client is not connected.
/// The method was called after the client was disposed.
SftpFileStream Open(string path, FileMode mode);
///
/// Opens a on the specified path, with the specified mode and access.
///
/// The file to open.
/// A value that specifies whether a file is created if one does not exist, and determines whether the contents of existing files are retained or overwritten.
/// A value that specifies the operations that can be performed on the file.
///
/// An unshared that provides access to the specified file, with the specified mode and access.
///
/// is null.
/// Client is not connected.
/// The method was called after the client was disposed.
SftpFileStream Open(string path, FileMode mode, FileAccess access);
///
/// Asynchronously opens a on the specified path, with the specified mode and access.
///
/// The file to open.
/// A value that specifies whether a file is created if one does not exist, and determines whether the contents of existing files are retained or overwritten.
/// A value that specifies the operations that can be performed on the file.
/// The to observe.
///
/// A that represents the asynchronous open operation.
/// The task result contains the that provides access to the specified file, with the specified mode and access.
///
/// is null.
/// Client is not connected.
/// The method was called after the client was disposed.
Task OpenAsync(string path, FileMode mode, FileAccess access, CancellationToken cancellationToken);
///
/// Opens an existing file for reading.
///
/// The file to be opened for reading.
///
/// A read-only on the specified path.
///
/// is null.
/// Client is not connected.
/// The method was called after the client was disposed.
SftpFileStream OpenRead(string path);
///
/// Opens an existing UTF-8 encoded text file for reading.
///
/// The file to be opened for reading.
///
/// A on the specified path.
///
/// is null.
/// Client is not connected.
/// The method was called after the client was disposed.
StreamReader OpenText(string path);
///
/// Opens a file for writing.
///
/// The file to be opened for writing.
///
/// An unshared object on the specified path with access.
///
/// is null.
/// Client is not connected.
/// The method was called after the client was disposed.
///
/// If the file does not exist, it is created.
///
SftpFileStream OpenWrite(string path);
///
/// Opens a binary file, reads the contents of the file into a byte array, and closes the file.
///
/// The file to open for reading.
///
/// A byte array containing the contents of the file.
///
/// is null.
/// Client is not connected.
/// The method was called after the client was disposed.
byte[] ReadAllBytes(string path);
///
/// Opens a text file, reads all lines of the file using UTF-8 encoding, and closes the file.
///
/// The file to open for reading.
///
/// A string array containing all lines of the file.
///
/// is null.
/// Client is not connected.
/// The method was called after the client was disposed.
string[] ReadAllLines(string path);
///
/// Opens a file, reads all lines of the file with the specified encoding, and closes the file.
///
/// The file to open for reading.
/// The encoding applied to the contents of the file.
///
/// A string array containing all lines of the file.
///
/// is null.
/// Client is not connected.
/// The method was called after the client was disposed.
string[] ReadAllLines(string path, Encoding encoding);
///
/// Opens a text file, reads all lines of the file with the UTF-8 encoding, and closes the file.
///
/// The file to open for reading.
///
/// A string containing all lines of the file.
///
/// is null.
/// Client is not connected.
/// The method was called after the client was disposed.
string ReadAllText(string path);
///
/// Opens a file, reads all lines of the file with the specified encoding, and closes the file.
///
/// The file to open for reading.
/// The encoding applied to the contents of the file.
///
/// A string containing all lines of the file.
///
/// is null.
/// Client is not connected.
/// The method was called after the client was disposed.
string ReadAllText(string path, Encoding encoding);
///
/// Reads the lines of a file with the UTF-8 encoding.
///
/// The file to read.
///
/// The lines of the file.
///
/// is null.
/// Client is not connected.
/// The method was called after the client was disposed.
IEnumerable ReadLines(string path);
///
/// Read the lines of a file that has a specified encoding.
///
/// The file to read.
/// The encoding that is applied to the contents of the file.
///
/// The lines of the file.
///
/// is null.
/// Client is not connected.
/// The method was called after the client was disposed.
IEnumerable ReadLines(string path, Encoding encoding);
///
/// Renames remote file from old path to new path.
///
/// Path to the old file location.
/// Path to the new file location.
/// is null. -or- or is null.
/// Client is not connected.
/// Permission to rename the file was denied by the remote host. -or- A SSH command was denied by the server.
/// A SSH error where is the message from the remote host.
/// The method was called after the client was disposed.
void RenameFile(string oldPath, string newPath);
///
/// Asynchronously renames remote file from old path to new path.
///
/// Path to the old file location.
/// Path to the new file location.
/// The to observe.
/// A that represents the asynchronous rename operation.
/// is null. -or- or is null.
/// Client is not connected.
/// Permission to rename the file was denied by the remote host. -or- A SSH command was denied by the server.
/// A SSH error where is the message from the remote host.
/// The method was called after the client was disposed.
Task RenameFileAsync(string oldPath, string newPath, CancellationToken cancellationToken);
///
/// Renames remote file from old path to new path.
///
/// Path to the old file location.
/// Path to the new file location.
/// if set to true then perform a posix rename.
/// is null. -or- or is null.
/// Client is not connected.
/// Permission to rename the file was denied by the remote host. -or- A SSH command was denied by the server.
/// A SSH error where is the message from the remote host.
/// The method was called after the client was disposed.
void RenameFile(string oldPath, string newPath, bool isPosix);
///
/// Sets the specified of the file on the specified path.
///
/// The path to the file.
/// The desired .
/// is null.
/// Client is not connected.
/// The method was called after the client was disposed.
void SetAttributes(string path, SftpFileAttributes fileAttributes);
///
/// Creates a symbolic link from old path to new path.
///
/// The old path.
/// The new path.
/// is null. -or- is null or contains only whitespace characters.
/// Client is not connected.
/// Permission to create the symbolic link was denied by the remote host. -or- A SSH command was denied by the server.
/// A SSH error where is the message from the remote host.
/// The method was called after the client was disposed.
void SymbolicLink(string path, string linkPath);
///
/// Synchronizes the directories.
///
/// The source path.
/// The destination path.
/// The search pattern.
///
/// A list of uploaded files.
///
/// is null.
/// is null or contains only whitespace.
/// was not found on the remote host.
IEnumerable SynchronizeDirectories(string sourcePath, string destinationPath, string searchPattern);
///
/// Uploads stream into remote file.
///
/// Data input stream.
/// Remote file path.
/// The upload callback.
/// is null.
/// is null or contains only whitespace characters.
/// Client is not connected.
/// Permission to upload the file was denied by the remote host. -or- A SSH command was denied by the server.
/// A SSH error where is the message from the remote host.
/// The method was called after the client was disposed.
///
/// Method calls made by this method to , may under certain conditions result in exceptions thrown by the stream.
///
void UploadFile(Stream input, string path, Action uploadCallback = null);
///
/// Uploads stream into remote file.
///
/// Data input stream.
/// Remote file path.
/// if set to true then existing file will be overwritten.
/// The upload callback.
/// is null.
/// is null or contains only whitespace characters.
/// Client is not connected.
/// Permission to upload the file was denied by the remote host. -or- A SSH command was denied by the server.
/// A SSH error where is the message from the remote host.
/// The method was called after the client was disposed.
///
/// Method calls made by this method to , may under certain conditions result in exceptions thrown by the stream.
///
void UploadFile(Stream input, string path, bool canOverride, Action uploadCallback = null);
///
/// Writes the specified byte array to the specified file, and closes the file.
///
/// The file to write to.
/// The bytes to write to the file.
/// is null.
/// Client is not connected.
/// The specified path is invalid, or its directory was not found on the remote host.
/// The method was called after the client was disposed.
///
///
/// If the target file already exists, it is overwritten. It is not first truncated to zero bytes.
///
///
/// If the target file does not exist, it is created.
///
///
void WriteAllBytes(string path, byte[] bytes);
///
/// Writes a collection of strings to the file using the UTF-8 encoding, and closes the file.
///
/// The file to write to.
/// The lines to write to the file.
/// is null.
/// Client is not connected.
/// The specified path is invalid, or its directory was not found on the remote host.
/// The method was called after the client was disposed.
///
///
/// The characters are written to the file using UTF-8 encoding without a Byte-Order Mark (BOM).
///
///
/// If the target file already exists, it is overwritten. It is not first truncated to zero bytes.
///
///
/// If the target file does not exist, it is created.
///
///
void WriteAllLines(string path, IEnumerable contents);
///
/// Writes a collection of strings to the file using the specified encoding, and closes the file.
///
/// The file to write to.
/// The lines to write to the file.
/// The character encoding to use.
/// is null.
/// Client is not connected.
/// The specified path is invalid, or its directory was not found on the remote host.
/// The method was called after the client was disposed.
///
///
/// If the target file already exists, it is overwritten. It is not first truncated to zero bytes.
///
///
/// If the target file does not exist, it is created.
///
///
void WriteAllLines(string path, IEnumerable contents, Encoding encoding);
///
/// Write the specified string array to the file using the UTF-8 encoding, and closes the file.
///
/// The file to write to.
/// The string array to write to the file.
/// is null.
/// Client is not connected.
/// The specified path is invalid, or its directory was not found on the remote host.
/// The method was called after the client was disposed.
///
///
/// The characters are written to the file using UTF-8 encoding without a Byte-Order Mark (BOM).
///
///
/// If the target file already exists, it is overwritten. It is not first truncated to zero bytes.
///
///
/// If the target file does not exist, it is created.
///
///
void WriteAllLines(string path, string[] contents);
///
/// Writes the specified string array to the file by using the specified encoding, and closes the file.
///
/// The file to write to.
/// The string array to write to the file.
/// An object that represents the character encoding applied to the string array.
/// is null.
/// Client is not connected.
/// The specified path is invalid, or its directory was not found on the remote host.
/// The method was called after the client was disposed.
///
///
/// If the target file already exists, it is overwritten. It is not first truncated to zero bytes.
///
///
/// If the target file does not exist, it is created.
///
///
void WriteAllLines(string path, string[] contents, Encoding encoding);
///
/// Writes the specified string to the file using the UTF-8 encoding, and closes the file.
///
/// The file to write to.
/// The string to write to the file.
/// is null.
/// Client is not connected.
/// The specified path is invalid, or its directory was not found on the remote host.
/// The method was called after the client was disposed.
///
///
/// The characters are written to the file using UTF-8 encoding without a Byte-Order Mark (BOM).
///
///
/// If the target file already exists, it is overwritten. It is not first truncated to zero bytes.
///
///
/// If the target file does not exist, it is created.
///
///
void WriteAllText(string path, string contents);
///
/// Writes the specified string to the file using the specified encoding, and closes the file.
///
/// The file to write to.
/// The string to write to the file.
/// The encoding to apply to the string.
/// is null.
/// Client is not connected.
/// The specified path is invalid, or its directory was not found on the remote host.
/// The method was called after the client was disposed.
///
///
/// If the target file already exists, it is overwritten. It is not first truncated to zero bytes.
///
///
/// If the target file does not exist, it is created.
///
///
void WriteAllText(string path, string contents, Encoding encoding);
}
}