Sftp Class
Namespace: Rebex.Net
Assembly: Rebex.Sftp.dll (version 7.0.9119)
Provides methods for communication with SFTP servers.
Syntax
public class Sftp : NetworkSession, ILogWriterProvider, IFtp, IDisposable
Inherited Members
Remarks
All members of this class are thread-safe.
Constructors
Name | Description |
---|---|
Sftp() | Initializes a new instance of the Sftp class. |
Fields
Name | Description |
---|---|
DefaultPort | Default SFTP port (22). |
Properties
Name | Description |
---|---|
DefaultLogWriter | Gets or sets a default log writer used by all new instances of NetworkSession object. Inherited from NetworkSession. |
Encoding | Gets or sets the Encoding to use to encode and decode command parameters and server responses. |
Fingerprint | Gets the server public key fingerprint (a SHA-256 hash of the server public key). |
InstanceId | Gets instance ID (intended for logging purposes). Inherited from NetworkSession. |
IsAuthenticated | Gets a value indicating whether the session is authenticated. |
IsConnected | Gets a value indicating whether the session is connected. |
LocalEndPoint | Gets the local client EndPoint. |
LogWriter | Gets or sets the LogWriter used by this object. Inherited from NetworkSession. |
MaxDownloadSpeed | Gets or sets the maximum allowed download speed, in kilobytes per second. For unlimited speed, set this to zero. |
MaxUploadSpeed | Gets or sets the maximum allowed upload speed, in kilobytes per second. For unlimited speed, set this to zero. |
ProtocolVersion | Gets the SFTP protocol version used by this session. This information is only available on fully initialized and authenticated sessions. |
Proxy | Gets or sets the network proxy to use to access a remote server. |
RemoteEndPoint | Gets the remote server EndPoint. |
ServerKey | Gets the server public key. |
ServerName | Gets the server name, if available. Inherited from NetworkSession. |
ServerPort | Gets the server port, if available. Inherited from NetworkSession. |
ServerType | Gets or sets the server type. |
Session | Gets the SSH session used by this SFTP session. |
Settings | Gets or sets SFTP object settings. |
Timeout | Gets or sets the length of time in milliseconds before the operation times out (specify -1 or 0 to indicate that the request does not time out). |
TransferType | Gets or sets the data transfer type. Make sure to set the ServerType property to the target OS first! |
UserName | Gets the authenticated user name, if available. Inherited from NetworkSession. |
Version | Gets the version of the SFTP component. |
Methods
Name | Description |
---|---|
AbortTransfer() | Aborts all pending file transfers (either file transfer or directory listing). |
AbortTransfer(Object) | Aborts pending transfers (either file transfer or directory listing) identified by the specified user-provided state object. |
Bind(ISocket) | Binds the Sftp object to an underlying stream socket. This method is experimental and intended for advanced users. |
Bind(SshSession) | Binds the Sftp object to an underlying SSH session. This makes it possible to run multiple SFTP sessions over a single SSH session. This can be used instead of Connect(String)/Login(String, String) methods. |
BindAsync(SshSession, Object) | Begins asynchronous Bind operation. Binds the Sftp object to an underlying SSH session. This makes it possible to run multiple SFTP sessions over a single SSH session. This can be used instead of Connect(String)/Login(String, String) methods. |
ChangeDirectory(String) | Changes the current working directory on the server. |
ChangeDirectoryAsync(String, Object) | Begins asynchronous ChangeDirectory operation. Changes the current working directory on the server. |
CheckConnectionState() | Checks whether the SFTP session is still connected. Throws an exception on error. |
Connect(String) | Connects to the SFTP server. |
Connect(String, Int32) | Connects to the SFTP server. |
ConnectAsync(String, Int32, Object) | Begins asynchronous Connect operation. Connects to the SFTP server. |
ConnectAsync(String, Object) | Begins asynchronous Connect operation. Connects to the SFTP server. |
CreateDirectory(String) | Creates a directory on the server. |
CreateDirectoryAsync(String, Object) | Begins asynchronous CreateDirectory operation. Creates a directory on the server. |
CreateLink(String, String, LinkType) | Creates a symbolic link or hard link on the server. |
CreateLinkAsync(String, String, LinkType, Object) | Begins asynchronous CreateLink operation. Creates a symbolic link or hard link on the server. |
CreateSymlink(String, String) | Creates a symbolic link on the server. |
CreateSymlinkAsync(String, String, Object) | Begins asynchronous CreateSymlink operation. Creates a symbolic link on the server. |
Delete(FileSet) | Deletes specified files and/or directories on the server. |
Delete(String, TraversalMode) | Deletes specified files and/or directories on the server. Accepts wildcards. |
DeleteAsync(FileSet, Object) | Begins asynchronous Delete operation. Deletes specified files and/or directories on the server. |
DeleteAsync(String, TraversalMode, Object) | Begins asynchronous Delete operation. Deletes specified files and/or directories on the server. Accepts wildcards. |
DeleteFile(String) | Deletes a file on the server. |
DeleteFileAsync(String, Object) | Begins asynchronous DeleteFile operation. Deletes a file on the server. |
DirectoryExists(String) | Detects whether the specified directory exists on the server. |
DirectoryExistsAsync(String, Object) | Begins asynchronous DirectoryExists operation. Detects whether the specified directory exists on the server. |
Disconnect() | Informs the server that the connection is about to close and terminates the connection. |
DisconnectAsync(Object) | Begins asynchronous Disconnect operation. Informs the server that the connection is about to close and terminates the connection. |
Dispose() | Disposes the Sftp object and the underlying SSH object. |
Dispose(Boolean) | Releases the unmanaged resources used by the Sftp and optionally releases the managed resources. |
Download(FileSet, String) | Downloads the specified files and/or directories from the SFTP server to the local directory. |
Download(FileSet, String, TransferMethod, ActionOnExistingFiles) | Downloads the specified files and/or directories from the SFTP server to the local directory. |
Download(String, String) | Downloads the specified file or directory hierarchy from the SFTP server to the local directory. Accepts wildcards. |
Download(String, String, TraversalMode) | Downloads the specified file or directory hierarchy from the SFTP server to the local directory. Accepts wildcards. |
Download(String, String, TraversalMode, TransferMethod, ActionOnExistingFiles) | Downloads the specified file or directory hierarchy from the SFTP server to the local directory. Accepts wildcards. |
DownloadAsync(FileSet, String, TransferMethod, ActionOnExistingFiles, Object) | Begins asynchronous Download operation. Downloads the specified files and/or directories from the SFTP server to the local directory. |
DownloadAsync(String, String, TraversalMode, TransferMethod, ActionOnExistingFiles, Object) | Begins asynchronous Download operation. Downloads the specified file or directory hierarchy from the SFTP server to the local directory. Accepts wildcards. |
FileExists(String) | Detects whether the specified file exists on the server. |
FileExistsAsync(String, Object) | Begins asynchronous FileExists operation. Detects whether the specified file exists on the server. |
Finalize() | Finalizer. Called by garbage collector during object destruction. |
GetChecksum(String, ChecksumAlgorithm) | Returns the checksum of the specified file on the server. Only works on servers that support the extension.
|
GetChecksum(String, ChecksumAlgorithm, Int64, Int64) | Returns the checksum of the specified file on the server. Only works on servers that support the extension.
|
GetChecksumAsync(String, ChecksumAlgorithm, Int64, Int64, Object) | Begins asynchronous GetChecksum operation. Returns the checksum of the specified file on the server. Only works on servers that support the extension.
|
GetChecksumAsync(String, ChecksumAlgorithm, Object) | Begins asynchronous GetChecksum operation. Returns the checksum of the specified file on the server. Only works on servers that support the extension.
|
GetConnectionState() | Checks whether the SFTP session is still connected and returns its state. |
GetCurrentDirectory() | Gets the absolute path of the current working directory on the remote server. |
GetDownloadStream(String) | Returns a Stream for reading data from the remote file. |
GetFile(String, Stream) | Downloads the remote file to the data stream. |
GetFile(String, Stream, Int64, Int64) | Downloads the specified part of the remote file to the data stream. |
GetFile(String, String) | Downloads the remote file to the local file, overriding it if it already exists. |
GetFile(String, String, Int64, Int64, Int64) | Downloads the specified part of the remote file to the specified offset of the local file. |
GetFileAsync(String, Stream, Int64, Int64, Object) | Begins asynchronous GetFile operation. Downloads the specified part of the remote file to the data stream. |
GetFileAsync(String, Stream, Object) | Begins asynchronous GetFile operation. Downloads the remote file to the data stream. |
GetFileAsync(String, String, Int64, Int64, Int64, Object) | Begins asynchronous GetFile operation. Downloads the specified part of the remote file to the specified offset of the local file. |
GetFileAsync(String, String, Object) | Begins asynchronous GetFile operation. Downloads the remote file to the local file, overriding it if it already exists. |
GetFileDateTime(String) | Retrieves the modification date and time of the specified remote file. |
GetFileDateTimeAsync(String, Object) | Begins asynchronous GetFileDateTime operation. Retrieves the modification date and time of the specified remote file. |
GetFileLength(String) | Retrieves the size of the specified remote file. |
GetFileLengthAsync(String, Object) | Begins asynchronous GetFileLength operation. Retrieves the size of the specified remote file. |
GetFileSystemInfo(String) | Gets drive information (such as free disk space) for the specified path. |
GetFileSystemInfoAsync(String, Object) | Begins asynchronous GetFileSystemInfo operation. Gets drive information (such as free disk space) for the specified path. |
GetHashCode() | Gets hash code for this object. Inherited from NetworkSession. |
GetHomeDirectory() | Gets the absolute path of the home directory path of currently logged user. |
GetInfo(String) | Retrieves a SftpItem containing the information about the specified remote file or directory. |
GetInfo(String, Boolean) | Retrieves a SftpItem containing the information about the specified remote file or directory. |
GetInfoAsync(String, Boolean, Object) | Begins asynchronous GetInfo operation. Retrieves a SftpItem containing the information about the specified remote file or directory. |
GetItems(FileSet) | Retrieves the list of files and directories specified by the |
GetItems(String) | Retrieves the list of files and directories. Matching directories are searched recursively. |
GetItems(String, TraversalMode) | Retrieves the list of files and directories. |
GetItemsAsync(FileSet, Object) | Begins asynchronous GetItems operation.
Retrieves the list of files and directories specified by the |
GetItemsAsync(String, TraversalMode, Object) | Begins asynchronous GetItems operation. Retrieves the list of files and directories. |
GetList() | Retrieves the list of files and directories in the current remote directory. |
GetList(String) | Retrieves the list of files and directories in the specified remote directory, or a list of files matching the specified mask. |
GetListAsync(Object) | Begins asynchronous GetList operation. Retrieves the list of files and directories in the current remote directory. |
GetListAsync(String, Object) | Begins asynchronous GetList operation. Retrieves the list of files and directories in the specified remote directory, or a list of files matching the specified mask. |
GetNameList() | Retrieves the list of file and directory names in the current remote directory. |
GetNameList(String) | Retrieves the list of file and directory names in the specified remote directory, or a list of names matching the specified mask. |
GetNameListAsync(Object) | Begins asynchronous GetNameList operation. Retrieves the list of file and directory names in the current remote directory. |
GetNameListAsync(String, Object) | Begins asynchronous GetNameList operation. Retrieves the list of file and directory names in the specified remote directory, or a list of names matching the specified mask. |
GetRawList() | Retrieves the list of files and directories in the current remote directory using a raw text format. |
GetRawList(String) | Retrieves the list of files and directories in the specified remote directory (or a list of files matching the specified mask) using a raw text format. |
GetRawListAsync(Object) | Begins asynchronous GetRawList operation. Retrieves the list of files and directories in the current remote directory using a raw text format. |
GetRawListAsync(String, Object) | Begins asynchronous GetRawList operation. Retrieves the list of files and directories in the specified remote directory (or a list of files matching the specified mask) using a raw text format. |
GetStream(String, FileMode) | Returns a Stream for reading and writing data from the remote file. |
GetStream(String, FileMode, FileAccess) | Returns a Stream for reading data from the remote file. |
GetStreamAsync(String, FileMode, FileAccess, Object) | Begins asynchronous GetStream operation. Returns a Stream for reading data from the remote file. |
GetUploadStream(String) | Returns a Stream for writing data to the remote file. The remote file is created if it doesn't exist, and truncated if it does. Use GetStream(String, FileMode) method if different behavior is desired. |
KeepAlive() | Sends an SSH 'ignore' packet to the server. This can be used to keep firewalls or routers that don't like inactive connection from closing idle session. |
KeepAliveAsync(Object) | Begins asynchronous KeepAlive operation. Sends an SSH 'ignore' packet to the server. This can be used to keep firewalls or routers that don't like inactive connection from closing idle session. |
Login() | Authenticates the user to the server interactively and initializes the SFTP session. Uses AuthenticationRequest event to request credentials. |
Login(SshGssApiCredentials) | Authenticates to the server using GSSAPI. Kerberos is only supported on Mono. NTLM is supported on Windows and partially on Mono. |
Login(String) | Authenticates the user to the server interactively and initializes the SFTP session. Uses AuthenticationRequest event to request credentials. |
Login(String, SshAuthenticationAgent) | Authenticates the user to the server using his private key and initializes the SFTP session. |
Login(String, SshPrivateKey) | Authenticates the user to the server using his private key and initializes the SFTP session. |
Login(String, String) | Authenticates the user to the server and initializes the SFTP session. |
Login(String, String, SshAuthenticationAgent) | Authenticates the user to the server using a combination of password and public key and initializes the SFTP session. |
Login(String, String, SshPrivateKey) | Authenticates the user to the server using a combination of password and public key and initializes the SFTP session. |
LoginAsync(SshGssApiCredentials, Object) | Begins asynchronous Login operation. Authenticates to the server using GSSAPI. Kerberos is only supported on Mono. NTLM is supported on Windows and partially on Mono. |
LoginAsync(Object) | Begins asynchronous Login operation. Authenticates the user to the server interactively and initializes the SFTP session. Uses AuthenticationRequest event to request credentials. |
LoginAsync(String, SshAuthenticationAgent, Object) | Begins asynchronous Login operation. Authenticates the user to the server using his private key and initializes the SFTP session. |
LoginAsync(String, SshPrivateKey, Object) | Begins asynchronous Login operation. Authenticates the user to the server using his private key and initializes the SFTP session. |
LoginAsync(String, Object) | Begins asynchronous Login operation. Authenticates the user to the server interactively and initializes the SFTP session. Uses AuthenticationRequest event to request credentials. |
LoginAsync(String, String, SshAuthenticationAgent, Object) | Begins asynchronous Login operation. Authenticates the user to the server using a combination of password and public key and initializes the SFTP session. |
LoginAsync(String, String, SshPrivateKey, Object) | Begins asynchronous Login operation. Authenticates the user to the server using a combination of password and public key and initializes the SFTP session. |
LoginAsync(String, String, Object) | Begins asynchronous Login operation. Authenticates the user to the server and initializes the SFTP session. |
OnCommandSent(SftpCommandSentEventArgs) | Raises the CommandSent event. |
OnResponseRead(SftpResponseReadEventArgs) | Raises the ResponseRead event. |
OnStateChanged(SftpStateChangedEventArgs) | Raises the Rebex.Net.Sftp.StateChanged event. |
OnTransferProgress(SftpTransferProgressEventArgs) | Raises the Rebex.Net.Sftp.TransferProgress event. |
PutFile(Stream, String) | Uploads the content of the data stream to the file on the server, overriding it if it already exists. |
PutFile(Stream, String, Int64, Int64) | Uploads the content of the data stream to the specified offset of the file on the SFTP server. |
PutFile(String, String) | Uploads the content of the local file to the file on the server, overriding it if it already exists. |
PutFile(String, String, Int64, Int64, Int64) | Uploads the specified part of the local file to the specified offset of the file on the SFTP server. |
PutFileAsync(Stream, String, Int64, Int64, Object) | Begins asynchronous PutFile operation. Uploads the content of the data stream to the specified offset of the file on the SFTP server. |
PutFileAsync(Stream, String, Object) | Begins asynchronous PutFile operation. Uploads the content of the data stream to the file on the server, overriding it if it already exists. |
PutFileAsync(String, String, Int64, Int64, Int64, Object) | Begins asynchronous PutFile operation. Uploads the specified part of the local file to the specified offset of the file on the SFTP server. |
PutFileAsync(String, String, Object) | Begins asynchronous PutFile operation. Uploads the content of the local file to the file on the server, overriding it if it already exists. |
RemoveDirectory(String) | Deletes an empty remote directory with the specified pathname. |
RemoveDirectoryAsync(String, Object) | Begins asynchronous RemoveDirectory operation. Deletes an empty remote directory with the specified pathname. |
Rename(String, String) | Renames or moves a file or directory on the server. |
RenameAsync(String, String, Object) | Begins asynchronous Rename operation. Renames or moves a file or directory on the server. |
ResolvePath(String) | Canonicalizes the specified remote path to an absolute path. Returns null if the specified path does not exist. |
ResolvePathAsync(String, Object) | Begins asynchronous ResolvePath operation. Canonicalizes the specified remote path to an absolute path. Returns null if the specified path does not exist. |
ResolveSymlink(String) | Resolves the symlink and returns the real path. |
ResolveSymlinkAsync(String, Object) | Begins asynchronous ResolveSymlink operation. Resolves the symlink and returns the real path. |
SetAttributes(String, SftpAttributes) | Sets the attributes of the remote file. |
SetAttributesAsync(String, SftpAttributes, Object) | Begins asynchronous SetAttributes operation. Sets the attributes of the remote file. |
SetFileDateTime(String, DateTime) | Sets the modification date and time of the specified remote file. |
SetFileDateTimeAsync(String, DateTime, Object) | Begins asynchronous SetFileDateTime operation. Sets the modification date and time of the specified remote file. |
SetSocketFactory(ISocketFactory) | Sets the socket factory to be used to create communication sockets. |
ToString() | Returns a string representation of this object. |
Upload(FileSet, String) | Uploads the specified local files and/or directories to the directory to the SFTP server. |
Upload(FileSet, String, TransferMethod, ActionOnExistingFiles) | Uploads the specified local files and/or directories to the directory to the SFTP server. |
Upload(String, String) | Uploads the specific local file or directory hierarchy to the directory to the SFTP server. Accepts wildcards. |
Upload(String, String, TraversalMode) | Uploads the specific local file or directory hierarchy to the directory to the SFTP server. Accepts wildcards. |
Upload(String, String, TraversalMode, TransferMethod, ActionOnExistingFiles) | Uploads the specified local file or directory hierarchy to the directory to the SFTP server. Accepts wildcards. |
UploadAsync(FileSet, String, TransferMethod, ActionOnExistingFiles, Object) | Begins asynchronous Upload operation. Uploads the specified local files and/or directories to the directory to the SFTP server. |
UploadAsync(String, String, TraversalMode, TransferMethod, ActionOnExistingFiles, Object) | Begins asynchronous Upload operation. Uploads the specified local file or directory hierarchy to the directory to the SFTP server. Accepts wildcards. |
Events
Name | Description |
---|---|
AuthenticationRequest | Occurs when an authentication request is received from the server that cannot be answered programmatically. |
BannerReceived | Occurs when a banner message is received from the server. |
CommandSent | Occurs when a command is send to the server. |
DeleteProgressChanged | Occurs when a significant action occurs in Delete method. Notifies the client about currently processing directory, currently deleting file and progress of the delete. |
FingerprintCheck | Occurs when a fingerprint is received from the server and needs to be validated. |
ListItemReceived | Occurs when a file and directory listing item is received by GetList(), GetRawList(), GetNameList() or GetItems methods. |
ProblemDetected | Occurs when a problem is detected in Download, Upload, Delete or GetItems methods, making it possible for the handler to choose a desired reaction. |
ResponseRead | Occurs when a response is received from the server. |
TransferProgressChanged | Occurs when a significant action occurs in Download, Upload methods. Notifies the client about currently processing directory, currently transferring file and progress of the transfer. |
Traversing | Occurs when a significant action occurs in Download, Upload, Delete or GetItems methods. Notifies the client about traversing hierarchy structure. |
Explicit Interface Implementations
Name | Description |
---|---|
IFtp.Abort() | Abort pending operations. |
IFtp.DeleteProgressChanged | Occurs when a significant action occurs in Delete(String, TraversalMode) method. Notifies the client about currently processing directory, currently deleting file and progress of the delete. |
IFtp.GetCurrentDirectoryAsync(Object) | Gets the absolute path of the current working directory on the remote server. |
IFtp.GetDownloadStream(String, SeekOrigin, Int64) | Returns a Stream for reading data from the remote file. |
IFtp.GetDownloadStreamAsync(String, SeekOrigin, Int64, Object) | Returns a Stream for reading data from the remote file. |
IFtp.GetFile(String, Stream, Int64) | Downloads the specified part of the remote file to the data stream. |
IFtp.GetFile(String, String, Int64, Int64) | Downloads the specified part of the remote file to the specified offset of the local file. |
IFtp.GetFileAsync(String, Stream, Int64, Object) | Downloads the specified part of the remote file to the data stream. |
IFtp.GetFileAsync(String, String, Int64, Int64, Object) | Downloads the specified part of the remote file to the specified offset of the local file. |
IFtp.GetInfo(String, Boolean) | Retrieves a FileSystemItem containing the information about the specified remote file or directory. |
IFtp.GetInfoAsync(String, Boolean, Object) | Retrieves a FileSystemItem containing the information about the specified remote file or directory. |
IFtp.GetItems(FileSet) | Retrieves the list of files and directories specified by the |
IFtp.GetItems(String) | Retrieves the list of files and directories. Matching directories are searched recursively. |
IFtp.GetItems(String, TraversalMode) | Retrieves the list of files and directories. |
IFtp.GetItemsAsync(FileSet, Object) | Retrieves the list of files and directories specified by the |
IFtp.GetItemsAsync(String, TraversalMode, Object) | Retrieves the list of files and directories. |
IFtp.GetList() | Retrieves the list of files and directories in the current server directory. |
IFtp.GetList(String) | Retrieves the list of files and directories in the current server directory. |
IFtp.GetListAsync(Object) | Retrieves the list of files and directories in the current server directory. |
IFtp.GetListAsync(String, Object) | Retrieves the list of files and directories in the current server directory. |
IFtp.GetUploadStream(String, SeekOrigin, Int64) | Returns a Stream for writing data to the remote file. |
IFtp.GetUploadStreamAsync(String, SeekOrigin, Int64, Object) | Returns a Stream for writing data to the remote file. |
IFtp.KeepAliveAsync(Object) | Sends a command to the server to keep the connection alive. |
IFtp.ListItemReceived | Occurs when a file and directory listing item is received by the GetList(), GetRawList(), GetNameList() or GetItems(String) methods. Notifies the client about currently processed item. |
IFtp.ProblemDetected | Occurs when a problem is detected in Download(String, String), Upload(String, String), Delete(String, TraversalMode) or GetItems(String) methods, making it possible for the handler to choose a desired reaction. |
IFtp.Settings | Gets the options set used by this object. |
IFtp.TransferProgressChanged | Occurs when a significant action occurs in Download(String, String), Upload(String, String) methods. Notifies the client about currently processing directory, currently transferring file and progress of the transfer. |
IFtp.TransferType | Gets or sets the data transfer type. |
IFtp.Traversing | Occurs when a significant action occurs in Download(String, String), Upload(String, String), Delete(String, TraversalMode) or GetItems(String) methods. Notifies the client about traversing hierarchy structure. |