C# Class Renci.SshNet.SftpClient

Inheritance: BaseClient
Datei anzeigen Open project: sshnet/SSH.NET Class Usage Examples

Public Methods

Method Description
AppendAllLines ( string path, IEnumerable contents ) : void

Appends lines to a file, and closes the file.

AppendAllLines ( string path, IEnumerable contents, Encoding encoding ) : void

Appends lines to a file by using a specified encoding, and closes the file.

AppendAllText ( string path, string contents ) : void

Appends the specified string to the file, and closes the file.

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

Appends the specified string to the file, and closes the file.

AppendText ( string path ) : StreamWriter

Creates a StreamWriter that appends UTF-8 encoded text to an existing file.

AppendText ( string path, Encoding encoding ) : StreamWriter

Creates a StreamWriter that appends text to an existing file using the specified encoding.

BeginDownloadFile ( string path, Stream output ) : IAsyncResult

Begins an asynchronous file downloading into the stream.

Method calls made by this method to output, may under certain conditions result in exceptions thrown by the stream.

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

Begins an asynchronous file downloading into the stream.

Method calls made by this method to output, may under certain conditions result in exceptions thrown by the stream.

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

Begins an asynchronous file downloading into the stream.

Method calls made by this method to output, may under certain conditions result in exceptions thrown by the stream.

BeginListDirectory ( string path, AsyncCallback asyncCallback, object state, Action listCallback = null ) : IAsyncResult

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

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

Begins the synchronize directories.

BeginUploadFile ( Stream input, string path ) : IAsyncResult

Begins an asynchronous uploading the stream into remote file.

Method calls made by this method to input, may under certain conditions result in exceptions thrown by the stream.

If the remote file already exists, it is overwritten and truncated.

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

Begins an asynchronous uploading the stream into remote file.

Method calls made by this method to input, may under certain conditions result in exceptions thrown by the stream.

If the remote file already exists, it is overwritten and truncated.

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

Begins an asynchronous uploading the stream into remote file.

Method calls made by this method to input, may under certain conditions result in exceptions thrown by the stream.

If the remote file already exists, it is overwritten and truncated.

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

Begins an asynchronous uploading the stream into remote file.

Method calls made by this method to input, may under certain conditions result in exceptions thrown by the stream.

When path refers to an existing file, set canOverride to true to overwrite and truncate that file. If canOverride is false, the upload will fail and EndUploadFile(IAsyncResult) will throw an SshException.

ChangeDirectory ( string path ) : void

Changes remote directory to path.

ChangePermissions ( string path, short mode ) : void

Changes permissions of file(s) to specified mode.

Create ( string path ) : SftpFileStream

Creates or overwrites a file in the specified path.

If the target file already exists, it is first truncated to zero bytes.

Create ( string path, int bufferSize ) : SftpFileStream

Creates or overwrites the specified file.

If the target file already exists, it is first truncated to zero bytes.

CreateDirectory ( string path ) : void

Creates remote directory specified by path.

CreateText ( string path ) : StreamWriter

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

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.

CreateText ( string path, Encoding encoding ) : StreamWriter

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

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.

Delete ( string path ) : void

Deletes the specified file or directory.

DeleteDirectory ( string path ) : void

Deletes remote directory specified by path.

DeleteFile ( string path ) : void

Deletes remote file specified by path.

DownloadFile ( string path, Stream output, Action downloadCallback = null ) : void

Downloads remote file specified by the path into the stream.

Method calls made by this method to output, may under certain conditions result in exceptions thrown by the stream.

EndDownloadFile ( IAsyncResult asyncResult ) : void

Ends an asynchronous file downloading into the stream.

EndListDirectory ( IAsyncResult asyncResult ) : IEnumerable

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

EndSynchronizeDirectories ( IAsyncResult asyncResult ) : IEnumerable

Ends the synchronize directories.

EndUploadFile ( IAsyncResult asyncResult ) : void

Ends an asynchronous uploading the stream into remote file.

Exists ( string path ) : bool

Checks whether file or directory exists;

Get ( string path ) : SftpFile

Gets reference to remote file or directory.

GetAttributes ( string path ) : SftpFileAttributes

Gets the SftpFileAttributes of the file on the path.

GetLastAccessTime ( string path ) : DateTime

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

GetLastAccessTimeUtc ( string path ) : DateTime

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

GetLastWriteTime ( string path ) : DateTime

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

GetLastWriteTimeUtc ( string path ) : DateTime

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

GetStatus ( string path ) : SftpFileSytemInformation

Gets status using [email protected] request.

ListDirectory ( string path, Action listCallback = null ) : IEnumerable

Retrieves list of files in remote directory.

Open ( string path, FileMode mode ) : SftpFileStream

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

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

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

OpenRead ( string path ) : SftpFileStream

Opens an existing file for reading.

OpenText ( string path ) : StreamReader

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

OpenWrite ( string path ) : SftpFileStream

Opens a file for writing.

If the file does not exist, it is created.

ReadAllBytes ( string path ) : byte[]

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

ReadAllLines ( string path ) : string[]

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

ReadAllLines ( string path, Encoding encoding ) : string[]

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

ReadAllText ( string path ) : string

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

ReadAllText ( string path, Encoding encoding ) : string

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

ReadLines ( string path ) : IEnumerable

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

ReadLines ( string path, Encoding encoding ) : IEnumerable

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

RenameFile ( string oldPath, string newPath ) : void

Renames remote file from old path to new path.

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

Renames remote file from old path to new path.

SetAttributes ( string path, SftpFileAttributes fileAttributes ) : void

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

SftpClient ( ConnectionInfo connectionInfo ) : System

Initializes a new instance of the SftpClient class.

SftpClient ( string host, string username ) : System

Initializes a new instance of the SftpClient class.

SftpClient ( string host, string username, string password ) : System

Initializes a new instance of the SftpClient class.

SymbolicLink ( string path, string linkPath ) : void

Creates a symbolic link from old path to new path.

SynchronizeDirectories ( string sourcePath, string destinationPath, string searchPattern ) : IEnumerable

Synchronizes the directories.

UploadFile ( Stream input, string path, Action uploadCallback = null ) : void

Uploads stream into remote file.

Method calls made by this method to input, may under certain conditions result in exceptions thrown by the stream.

UploadFile ( Stream input, string path, bool canOverride, Action uploadCallback = null ) : void

Uploads stream into remote file.

Method calls made by this method to input, may under certain conditions result in exceptions thrown by the stream.

WriteAllBytes ( string path, byte bytes ) : void

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

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.

WriteAllLines ( string path, IEnumerable contents ) : void

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

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.

WriteAllLines ( string path, IEnumerable contents, Encoding encoding ) : void

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

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.

WriteAllLines ( string path, string contents ) : void

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

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.

WriteAllLines ( string path, string contents, Encoding encoding ) : void

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

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.

WriteAllText ( string path, string contents ) : void

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

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.

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

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

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.

Protected Methods

Method Description
Dispose ( bool disposing ) : void

Releases unmanaged and - optionally - managed resources

OnConnected ( ) : void

Called when client is connected to the server.

OnDisconnecting ( ) : void

Called when client is disconnecting from the server.

Private Methods

Method Description
InternalDownloadFile ( string path, Stream output, SftpDownloadAsyncResult asyncResult, Action downloadCallback ) : void

Internals the download file.

InternalListDirectory ( string path, Action listCallback ) : IEnumerable

Internals the list directory.

InternalSynchronizeDirectories ( string sourcePath, string destinationPath, string searchPattern, SftpSynchronizeDirectoriesAsyncResult asynchResult ) : IEnumerable
InternalUploadFile ( Stream input, string path, Flags flags, SftpUploadAsyncResult asyncResult, Action uploadCallback ) : void

Internals the upload file.

SetLastAccessTime ( string path, DateTime lastAccessTime ) : void
SetLastAccessTimeUtc ( string path, DateTime lastAccessTimeUtc ) : void
SetLastWriteTime ( string path, DateTime lastWriteTime ) : void
SetLastWriteTimeUtc ( string path, DateTime lastWriteTimeUtc ) : void
SftpClient ( ConnectionInfo connectionInfo, bool ownsConnectionInfo ) : System

Initializes a new instance of the SftpClient class.

If ownsConnectionInfo is true, the connection info will be disposed when this instance is disposed.

SftpClient ( ConnectionInfo connectionInfo, bool ownsConnectionInfo, IServiceFactory serviceFactory ) : System

Initializes a new instance of the SftpClient class.

If ownsConnectionInfo is true, the connection info will be disposed when this instance is disposed.

SftpClient ( string host, int port, string username ) : System
SftpClient ( string host, int port, string username, string password ) : System

Method Details

AppendAllLines() public method

Appends lines to a file, and closes the file.
isnull -or- is null. Client is not connected. was not found on the remote host. The method was called after the client was disposed.
public AppendAllLines ( string path, IEnumerable contents ) : void
path string The file to append the lines to. The file is created if it does not already exist.
contents IEnumerable The lines to append to the file.
return void

AppendAllLines() public method

Appends lines to a file by using a specified encoding, and closes the file.
is null. -or- is null. -or- is null. Client is not connected. was not found on the remote host. The method was called after the client was disposed.
public AppendAllLines ( string path, IEnumerable contents, Encoding encoding ) : void
path string The file to append the lines to. The file is created if it does not already exist.
contents IEnumerable The lines to append to the file.
encoding System.Text.Encoding The character encoding to use.
return void

AppendAllText() public method

Appends the specified string to the file, and closes the file.
is null. -or- is null. Client is not connected. was not found on the remote host. The method was called after the client was disposed.
public AppendAllText ( string path, string contents ) : void
path string The file to append the specified string to.
contents string The string to append to the file.
return void

AppendAllText() public method

Appends the specified string to the file, and closes the file.
is null. -or- is null. -or- is null. Client is not connected. was not found on the remote host. The method was called after the client was disposed.
public AppendAllText ( string path, string contents, Encoding encoding ) : void
path string The file to append the specified string to.
contents string The string to append to the file.
encoding System.Text.Encoding The character encoding to use.
return void

AppendText() public method

Creates a StreamWriter that appends UTF-8 encoded text to an existing file.
is null. Client is not connected. was not found on the remote host. The method was called after the client was disposed.
public AppendText ( string path ) : StreamWriter
path string The path to the file to append to.
return System.IO.StreamWriter

AppendText() public method

Creates a StreamWriter that appends text to an existing file using the specified encoding.
is null. -or- is null. Client is not connected. was not found on the remote host. The method was called after the client was disposed.
public AppendText ( string path, Encoding encoding ) : StreamWriter
path string The path to the file to append to.
encoding System.Text.Encoding The character encoding to use.
return System.IO.StreamWriter

BeginDownloadFile() public method

Begins an asynchronous file downloading into the stream.
Method calls made by this method to output, may under certain conditions result in exceptions thrown by the stream.
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.
public BeginDownloadFile ( string path, Stream output ) : IAsyncResult
path string The path.
output Stream The output.
return IAsyncResult

BeginDownloadFile() public method

Begins an asynchronous file downloading into the stream.
Method calls made by this method to output, may under certain conditions result in exceptions thrown by the stream.
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.
public BeginDownloadFile ( string path, Stream output, AsyncCallback asyncCallback ) : IAsyncResult
path string The path.
output Stream The output.
asyncCallback AsyncCallback The method to be called when the asynchronous write operation is completed.
return IAsyncResult

BeginDownloadFile() public method

Begins an asynchronous file downloading into the stream.
Method calls made by this method to output, may under certain conditions result in exceptions thrown by the stream.
is null. is null or contains only whitespace characters. The method was called after the client was disposed.
public BeginDownloadFile ( string path, Stream output, AsyncCallback asyncCallback, object state, Action downloadCallback = null ) : IAsyncResult
path string The path.
output Stream The output.
asyncCallback AsyncCallback The method to be called when the asynchronous write operation is completed.
state object A user-provided object that distinguishes this particular asynchronous write request from other requests.
downloadCallback Action The download callback.
return IAsyncResult

BeginListDirectory() public method

Begins an asynchronous operation of retrieving list of files in remote directory.
The method was called after the client was disposed.
public BeginListDirectory ( string path, AsyncCallback asyncCallback, object state, Action listCallback = null ) : IAsyncResult
path string The path.
asyncCallback AsyncCallback The method to be called when the asynchronous write operation is completed.
state object A user-provided object that distinguishes this particular asynchronous write request from other requests.
listCallback Action The list callback.
return IAsyncResult

BeginSynchronizeDirectories() public method

Begins the synchronize directories.
is null. is null or contains only whitespace.
public BeginSynchronizeDirectories ( string sourcePath, string destinationPath, string searchPattern, AsyncCallback asyncCallback, object state ) : IAsyncResult
sourcePath string The source path.
destinationPath string The destination path.
searchPattern string The search pattern.
asyncCallback AsyncCallback The async callback.
state object The state.
return IAsyncResult

BeginUploadFile() public method

Begins an asynchronous uploading the stream into remote file.

Method calls made by this method to input, may under certain conditions result in exceptions thrown by the stream.

If the remote file already exists, it is overwritten and truncated.

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.
public BeginUploadFile ( Stream input, string path ) : IAsyncResult
input Stream Data input stream.
path string Remote file path.
return IAsyncResult

BeginUploadFile() public method

Begins an asynchronous uploading the stream into remote file.

Method calls made by this method to input, may under certain conditions result in exceptions thrown by the stream.

If the remote file already exists, it is overwritten and truncated.

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.
public BeginUploadFile ( Stream input, string path, AsyncCallback asyncCallback ) : IAsyncResult
input Stream Data input stream.
path string Remote file path.
asyncCallback AsyncCallback The method to be called when the asynchronous write operation is completed.
return IAsyncResult

BeginUploadFile() public method

Begins an asynchronous uploading the stream into remote file.

Method calls made by this method to input, may under certain conditions result in exceptions thrown by the stream.

If the remote file already exists, it is overwritten and truncated.

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.
public BeginUploadFile ( Stream input, string path, AsyncCallback asyncCallback, object state, Action uploadCallback = null ) : IAsyncResult
input Stream Data input stream.
path string Remote file path.
asyncCallback AsyncCallback The method to be called when the asynchronous write operation is completed.
state object A user-provided object that distinguishes this particular asynchronous write request from other requests.
uploadCallback Action The upload callback.
return IAsyncResult

BeginUploadFile() public method

Begins an asynchronous uploading the stream into remote file.

Method calls made by this method to input, may under certain conditions result in exceptions thrown by the stream.

When path refers to an existing file, set canOverride to true to overwrite and truncate that file. If canOverride is false, the upload will fail and EndUploadFile(IAsyncResult) will throw an SshException.

is null. is null or contains only whitespace characters. The method was called after the client was disposed.
public BeginUploadFile ( Stream input, string path, bool canOverride, AsyncCallback asyncCallback, object state, Action uploadCallback = null ) : IAsyncResult
input Stream Data input stream.
path string Remote file path.
canOverride bool Specified whether an existing file can be overwritten.
asyncCallback AsyncCallback The method to be called when the asynchronous write operation is completed.
state object A user-provided object that distinguishes this particular asynchronous write request from other requests.
uploadCallback Action The upload callback.
return IAsyncResult

ChangeDirectory() public method

Changes remote directory to 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.
public ChangeDirectory ( string path ) : void
path string New directory path.
return void

ChangePermissions() public method

Changes permissions of file(s) to specified 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.
public ChangePermissions ( string path, short mode ) : void
path string File(s) path, may match multiple files.
mode short The mode.
return void

Create() public method

Creates or overwrites a file in the specified path.
If the target file already exists, it is first truncated to zero bytes.
is null. Client is not connected. The method was called after the client was disposed.
public Create ( string path ) : SftpFileStream
path string The path and name of the file to create.
return Renci.SshNet.Sftp.SftpFileStream

Create() public method

Creates or overwrites the specified file.
If the target file already exists, it is first truncated to zero bytes.
is null. Client is not connected. The method was called after the client was disposed.
public Create ( string path, int bufferSize ) : SftpFileStream
path string The path and name of the file to create.
bufferSize int The maximum number of bytes buffered for reads and writes to the file.
return Renci.SshNet.Sftp.SftpFileStream

CreateDirectory() public method

Creates remote directory specified by path.
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.
public CreateDirectory ( string path ) : void
path string Directory path to create.
return void

CreateText() public method

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

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.

is null. Client is not connected. The method was called after the client was disposed.
public CreateText ( string path ) : StreamWriter
path string The file to be opened for writing.
return System.IO.StreamWriter

CreateText() public method

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

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.

is null. Client is not connected. The method was called after the client was disposed.
public CreateText ( string path, Encoding encoding ) : StreamWriter
path string The file to be opened for writing.
encoding Encoding The character encoding to use.
return StreamWriter

Delete() public method

Deletes the specified file or directory.
is null. Client is not connected. was not found on the remote host. The method was called after the client was disposed.
public Delete ( string path ) : void
path string The name of the file or directory to be deleted. Wildcard characters are not supported.
return void

DeleteDirectory() public method

Deletes remote directory specified by 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.
public DeleteDirectory ( string path ) : void
path string Directory to be deleted path.
return void

DeleteFile() public method

Deletes remote file specified by 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.
public DeleteFile ( string path ) : void
path string File to be deleted path.
return void

Dispose() protected method

Releases unmanaged and - optionally - managed resources
protected Dispose ( bool disposing ) : void
disposing bool true to release both managed and unmanaged resources; false to release only unmanaged resources.
return void

DownloadFile() public method

Downloads remote file specified by the path into the stream.
Method calls made by this method to output, may under certain conditions result in exceptions thrown by the stream.
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.
public DownloadFile ( string path, Stream output, Action downloadCallback = null ) : void
path string File to download.
output Stream Stream to write the file into.
downloadCallback Action The download callback.
return void

EndDownloadFile() public method

Ends an asynchronous file downloading into the stream.
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.
public EndDownloadFile ( IAsyncResult asyncResult ) : void
asyncResult IAsyncResult The pending asynchronous SFTP request.
return void

EndListDirectory() public method

Ends an asynchronous operation of retrieving list of files in remote directory.
The object did not come from the corresponding async method on this type.-or- was called multiple times with the same .
public EndListDirectory ( IAsyncResult asyncResult ) : IEnumerable
asyncResult IAsyncResult The pending asynchronous SFTP request.
return IEnumerable

EndSynchronizeDirectories() public method

Ends the synchronize directories.
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.
public EndSynchronizeDirectories ( IAsyncResult asyncResult ) : IEnumerable
asyncResult IAsyncResult The async result.
return IEnumerable

EndUploadFile() public method

Ends an asynchronous uploading the stream into remote file.
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.
public EndUploadFile ( IAsyncResult asyncResult ) : void
asyncResult IAsyncResult The pending asynchronous SFTP request.
return void

Exists() public method

Checks whether file or directory exists;
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.
public Exists ( string path ) : bool
path string The path.
return bool

Get() public method

Gets reference to remote file or directory.
Client is not connected. was not found on the remote host. is null. The method was called after the client was disposed.
public Get ( string path ) : SftpFile
path string The path.
return SftpFile

GetAttributes() public method

Gets the SftpFileAttributes 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.
public GetAttributes ( string path ) : SftpFileAttributes
path string The path to the file.
return SftpFileAttributes

GetLastAccessTime() public method

Returns the date and time the specified file or directory was last accessed.
is null. Client is not connected. The method was called after the client was disposed.
public GetLastAccessTime ( string path ) : DateTime
path string The file or directory for which to obtain access date and time information.
return DateTime

GetLastAccessTimeUtc() public method

Returns the date and time, in coordinated universal time (UTC), that the specified file or directory was last accessed.
is null. Client is not connected. The method was called after the client was disposed.
public GetLastAccessTimeUtc ( string path ) : DateTime
path string The file or directory for which to obtain access date and time information.
return DateTime

GetLastWriteTime() public method

Returns the date and time the specified file or directory was last written to.
is null. Client is not connected. The method was called after the client was disposed.
public GetLastWriteTime ( string path ) : DateTime
path string The file or directory for which to obtain write date and time information.
return DateTime

GetLastWriteTimeUtc() public method

Returns the date and time, in coordinated universal time (UTC), that the specified file or directory was last written to.
is null. Client is not connected. The method was called after the client was disposed.
public GetLastWriteTimeUtc ( string path ) : DateTime
path string The file or directory for which to obtain write date and time information.
return DateTime

GetStatus() public method

Gets status using [email protected] request.
Client is not connected. is null. The method was called after the client was disposed.
public GetStatus ( string path ) : SftpFileSytemInformation
path string The path.
return SftpFileSytemInformation

ListDirectory() public method

Retrieves list of files in remote directory.
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.
public ListDirectory ( string path, Action listCallback = null ) : IEnumerable
path string The path.
listCallback Action The list callback.
return IEnumerable

OnConnected() protected method

Called when client is connected to the server.
protected OnConnected ( ) : void
return void

OnDisconnecting() protected method

Called when client is disconnecting from the server.
protected OnDisconnecting ( ) : void
return void

Open() public method

Opens a SftpFileStream on the specified path with read/write access.
is null. Client is not connected. The method was called after the client was disposed.
public Open ( string path, FileMode mode ) : SftpFileStream
path string The file to open.
mode FileMode 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.
return SftpFileStream

Open() public method

Opens a SftpFileStream on the specified path, with the specified mode and access.
is null. Client is not connected. The method was called after the client was disposed.
public Open ( string path, FileMode mode, FileAccess access ) : SftpFileStream
path string The file to open.
mode FileMode 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.
access FileAccess A value that specifies the operations that can be performed on the file.
return SftpFileStream

OpenRead() public method

Opens an existing file for reading.
is null. Client is not connected. The method was called after the client was disposed.
public OpenRead ( string path ) : SftpFileStream
path string The file to be opened for reading.
return SftpFileStream

OpenText() public method

Opens an existing UTF-8 encoded text file for reading.
is null. Client is not connected. The method was called after the client was disposed.
public OpenText ( string path ) : StreamReader
path string The file to be opened for reading.
return StreamReader

OpenWrite() public method

Opens a file for writing.
If the file does not exist, it is created.
is null. Client is not connected. The method was called after the client was disposed.
public OpenWrite ( string path ) : SftpFileStream
path string The file to be opened for writing.
return SftpFileStream

ReadAllBytes() public method

Opens a binary file, reads the contents of the file into a byte array, and closes the file.
is null. Client is not connected. The method was called after the client was disposed.
public ReadAllBytes ( string path ) : byte[]
path string The file to open for reading.
return byte[]

ReadAllLines() public method

Opens a text file, reads all lines of the file using UTF-8 encoding, and closes the file.
is null. Client is not connected. The method was called after the client was disposed.
public ReadAllLines ( string path ) : string[]
path string The file to open for reading.
return string[]

ReadAllLines() public method

Opens a file, reads all lines of the file with the specified encoding, and closes the file.
is null. Client is not connected. The method was called after the client was disposed.
public ReadAllLines ( string path, Encoding encoding ) : string[]
path string The file to open for reading.
encoding Encoding The encoding applied to the contents of the file.
return string[]

ReadAllText() public method

Opens a text file, reads all lines of the file with the UTF-8 encoding, and closes the file.
is null. Client is not connected. The method was called after the client was disposed.
public ReadAllText ( string path ) : string
path string The file to open for reading.
return string

ReadAllText() public method

Opens a file, reads all lines of the file with the specified encoding, and closes the file.
is null. Client is not connected. The method was called after the client was disposed.
public ReadAllText ( string path, Encoding encoding ) : string
path string The file to open for reading.
encoding Encoding The encoding applied to the contents of the file.
return string

ReadLines() public method

Reads the lines of a file with the UTF-8 encoding.
is null. Client is not connected. The method was called after the client was disposed.
public ReadLines ( string path ) : IEnumerable
path string The file to read.
return IEnumerable

ReadLines() public method

Read the lines of a file that has a specified encoding.
is null. Client is not connected. The method was called after the client was disposed.
public ReadLines ( string path, Encoding encoding ) : IEnumerable
path string The file to read.
encoding Encoding The encoding that is applied to the contents of the file.
return IEnumerable

RenameFile() public method

Renames remote file from old path to new path.
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.
public RenameFile ( string oldPath, string newPath ) : void
oldPath string Path to the old file location.
newPath string Path to the new file location.
return void

RenameFile() public method

Renames remote file from old path to new path.
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.
public RenameFile ( string oldPath, string newPath, bool isPosix ) : void
oldPath string Path to the old file location.
newPath string Path to the new file location.
isPosix bool if set to true then perform a posix rename.
return void

SetAttributes() public method

Sets the specified SftpFileAttributes of the file on the specified path.
is null. Client is not connected. The method was called after the client was disposed.
public SetAttributes ( string path, SftpFileAttributes fileAttributes ) : void
path string The path to the file.
fileAttributes SftpFileAttributes The desired .
return void

SftpClient() public method

Initializes a new instance of the SftpClient class.
is null.
public SftpClient ( ConnectionInfo connectionInfo ) : System
connectionInfo ConnectionInfo The connection info.
return System

SftpClient() public method

Initializes a new instance of the SftpClient class.
is null. is invalid. -or- is null or contains only whitespace characters.
public SftpClient ( string host, string username ) : System
host string Connection host.
username string Authentication username.
return System

SftpClient() public method

Initializes a new instance of the SftpClient class.
is null. is invalid. -or- is null contains only whitespace characters.
public SftpClient ( string host, string username, string password ) : System
host string Connection host.
username string Authentication username.
password string Authentication password.
return System

SymbolicLink() public method

Creates a symbolic link from old path to 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.
public SymbolicLink ( string path, string linkPath ) : void
path string The old path.
linkPath string The new path.
return void

SynchronizeDirectories() public method

Synchronizes the directories.
is null. is null or contains only whitespace. was not found on the remote host.
public SynchronizeDirectories ( string sourcePath, string destinationPath, string searchPattern ) : IEnumerable
sourcePath string The source path.
destinationPath string The destination path.
searchPattern string The search pattern.
return IEnumerable

UploadFile() public method

Uploads stream into remote file.
Method calls made by this method to input, may under certain conditions result in exceptions thrown by the stream.
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.
public UploadFile ( Stream input, string path, Action uploadCallback = null ) : void
input Stream Data input stream.
path string Remote file path.
uploadCallback Action The upload callback.
return void

UploadFile() public method

Uploads stream into remote file.
Method calls made by this method to input, may under certain conditions result in exceptions thrown by the stream.
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.
public UploadFile ( Stream input, string path, bool canOverride, Action uploadCallback = null ) : void
input Stream Data input stream.
path string Remote file path.
canOverride bool if set to true then existing file will be overwritten.
uploadCallback Action The upload callback.
return void

WriteAllBytes() public method

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

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.

is null. Client is not connected. The method was called after the client was disposed.
public WriteAllBytes ( string path, byte bytes ) : void
path string The file to write to.
bytes byte The bytes to write to the file.
return void

WriteAllLines() public method

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

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.

is null. Client is not connected. The method was called after the client was disposed.
public WriteAllLines ( string path, IEnumerable contents ) : void
path string The file to write to.
contents IEnumerable The lines to write to the file.
return void

WriteAllLines() public method

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

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.

is null. Client is not connected. The method was called after the client was disposed.
public WriteAllLines ( string path, IEnumerable contents, Encoding encoding ) : void
path string The file to write to.
contents IEnumerable The lines to write to the file.
encoding Encoding The character encoding to use.
return void

WriteAllLines() public method

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

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.

is null. Client is not connected. The method was called after the client was disposed.
public WriteAllLines ( string path, string contents ) : void
path string The file to write to.
contents string The string array to write to the file.
return void

WriteAllLines() public method

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

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.

is null. Client is not connected. The method was called after the client was disposed.
public WriteAllLines ( string path, string contents, Encoding encoding ) : void
path string The file to write to.
contents string The string array to write to the file.
encoding Encoding An object that represents the character encoding applied to the string array.
return void

WriteAllText() public method

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

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.

is null. Client is not connected. The method was called after the client was disposed.
public WriteAllText ( string path, string contents ) : void
path string The file to write to.
contents string The string to write to the file.
return void

WriteAllText() public method

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

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.

is null. Client is not connected. The method was called after the client was disposed.
public WriteAllText ( string path, string contents, Encoding encoding ) : void
path string The file to write to.
contents string The string to write to the file.
encoding Encoding The encoding to apply to the string.
return void