C# Класс Granados.Poderosa.SFTP.SFTPClient

SFTP Client

This class is designed to be used in the worker thread.

Some methods block thread while waiting for the response.

Referenced specification:
IETF Network Working Group Internet Draft
SSH File Transfer Protocol
draft-ietf-secsh-filexfer-02 (protocol version 3)
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
Close ( ) : void

Close channel.

CreateDirectory ( string path ) : void

Create directory.

DownloadFile ( string remotePath, string localPath, Granados.Poderosa.FileTransfer.Cancellation cancellation, SFTPFileTransferProgressDelegate progressDelegate ) : void

Download a file.

Even if download failed, local file is not deleted.

GetDirectoryEntries ( string directoryPath ) : Granados.Poderosa.SFTP.SFTPFileInfo[]

Gets directory entries in the specified directory path.

GetFileInformations ( string path, bool lstat ) : Granados.Poderosa.SFTP.SFTPFileAttributes

Get file informations.

GetRealPath ( string path ) : string

Gets canonical path.

Init ( ) : void

Initialize

Send SSH_FXP_INIT and receive SSH_FXP_VERSION.

OpenSFTPChannel ( ISSHConnection connection ) : SFTPClient

Opens SFTP channel and creates a new instance.

RemoveDirectory ( string path ) : void

Remove directory.

RemoveFile ( string path ) : void

Remove file.

Rename ( string oldPath, string newPath ) : void

Rename file or directory.

SetPermissions ( string path, int permissions ) : void

Set permissions of the file or directory.

UploadFile ( string localPath, string remotePath, Granados.Poderosa.FileTransfer.Cancellation cancellation, SFTPFileTransferProgressDelegate progressDelegate ) : void

Upload a file.

Приватные методы

Метод Описание
CheckStatus ( ) : void
CloseHandle ( uint requestId, byte handle ) : void
OpenDir ( uint requestId, string directoryPath ) : byte[]
OpenFile ( uint requestId, string filePath, uint flags ) : byte[]
ReadDir ( uint requestId, byte handle ) : ICollection
ReadFile ( uint requestId, byte handle, ulong offset, int length, byte buffer ) : int
ReadFileAttributes ( Granados.IO.SSHDataReader dataReader ) : Granados.Poderosa.SFTP.SFTPFileAttributes
ReadFileInfo ( Granados.IO.SSHDataReader dataReader, Encoding encoding ) : Granados.Poderosa.SFTP.SFTPFileInfo
SFTPClient ( ISSHChannel channel, SFTPClientChannelEventHandler eventHandler ) : System

Constructor

Transmit ( SFTPPacket packet ) : void
TransmitPacketAndWaitForStatusOK ( uint requestId, SFTPPacket packet ) : void
WaitHandle ( SFTPPacket requestPacket, uint requestId ) : byte[]
WaitReady ( ) : bool

Waits for channel status to be "READY". The current thread is blocked until the status comes to "READY" or "CLOSED".

WriteFile ( uint requestId, byte handle, ulong offset, byte buff, int length ) : void

Описание методов

Close() публичный Метод

Close channel.
public Close ( ) : void
Результат void

CreateDirectory() публичный Метод

Create directory.
Operation failed. Timeout has occured. Invalid status An exception which was thrown while processing the response.
public CreateDirectory ( string path ) : void
path string Directory path to create.
Результат void

DownloadFile() публичный Метод

Download a file.
Even if download failed, local file is not deleted.
Operation failed. Timeout has occured. Invalid status. Error. Error.
public DownloadFile ( string remotePath, string localPath, Granados.Poderosa.FileTransfer.Cancellation cancellation, SFTPFileTransferProgressDelegate progressDelegate ) : void
remotePath string Remote file path to download.
localPath string Local file path to save.
cancellation Granados.Poderosa.FileTransfer.Cancellation An object to request the cancellation. Set null if the cancellation is not needed.
progressDelegate SFTPFileTransferProgressDelegate Delegate to notify progress. Set null if notification is not needed.
Результат void

GetDirectoryEntries() публичный Метод

Gets directory entries in the specified directory path.
Operation failed. Timeout has occured. Invalid status.
public GetDirectoryEntries ( string directoryPath ) : Granados.Poderosa.SFTP.SFTPFileInfo[]
directoryPath string Directory path.
Результат Granados.Poderosa.SFTP.SFTPFileInfo[]

GetFileInformations() публичный Метод

Get file informations.
Operation failed. Timeout has occured. Invalid status An exception which was thrown while processing the response.
public GetFileInformations ( string path, bool lstat ) : Granados.Poderosa.SFTP.SFTPFileAttributes
path string File path.
lstat bool Specifies to use lstat. Symbolic link is not followed and informations about the symbolic link are returned.
Результат Granados.Poderosa.SFTP.SFTPFileAttributes

GetRealPath() публичный Метод

Gets canonical path.
Operation failed. Timeout has occured. Invalid status.
public GetRealPath ( string path ) : string
path string Path to be canonicalized.
Результат string

Init() публичный Метод

Initialize
Send SSH_FXP_INIT and receive SSH_FXP_VERSION.
Timeout has occured. Invalid status An exception which was thrown while processing the response.
public Init ( ) : void
Результат void

OpenSFTPChannel() публичный статический Метод

Opens SFTP channel and creates a new instance.
public static OpenSFTPChannel ( ISSHConnection connection ) : SFTPClient
connection ISSHConnection SSH2 connection object
Результат SFTPClient

RemoveDirectory() публичный Метод

Remove directory.
Operation failed. Timeout has occured. Invalid status An exception which was thrown while processing the response.
public RemoveDirectory ( string path ) : void
path string Directory path to remove.
Результат void

RemoveFile() публичный Метод

Remove file.
Operation failed. Timeout has occured. Invalid status An exception which was thrown while processing the response.
public RemoveFile ( string path ) : void
path string File path to remove.
Результат void

Rename() публичный Метод

Rename file or directory.
Operation failed. Timeout has occured. Invalid status An exception which was thrown while processing the response.
public Rename ( string oldPath, string newPath ) : void
oldPath string Old path.
newPath string New path.
Результат void

SetPermissions() публичный Метод

Set permissions of the file or directory.
Operation failed. Timeout has occured. Invalid status An exception which was thrown while processing the response.
public SetPermissions ( string path, int permissions ) : void
path string Path.
permissions int Permissions to set.
Результат void

UploadFile() публичный Метод

Upload a file.
Operation failed. Timeout has occured. Invalid status. Error. Error.
public UploadFile ( string localPath, string remotePath, Granados.Poderosa.FileTransfer.Cancellation cancellation, SFTPFileTransferProgressDelegate progressDelegate ) : void
localPath string Local file path to upload.
remotePath string Remote file path to write.
cancellation Granados.Poderosa.FileTransfer.Cancellation An object to request the cancellation. Set null if the cancellation is not needed.
progressDelegate SFTPFileTransferProgressDelegate Delegate to notify progress. Set null if notification is not needed.
Результат void