Table of Contents

Class Sftp

Namespace
Tamir.SharpSsh
Assembly
SLSSH.dll

Provides functionality to communicate with a server via the SSH File Transfer Protocol (SFTP).

public class Sftp : SshTransferProtocolBase, ITransferProtocol
Inheritance
Sftp
Implements
Inherited Members
Extension Methods

Examples

Sftp sftp;
try
{
	sftp = new Sftp(host, userName);

	if (authenticationMethod == AuthenticationType.Password)
	{
		sftp.Password = connInfo.password;
	}
	else if (File.Exists(identityFile) && authenticationMethod == AuthenticationType.IdentityFile)
	{				
		sftp.AddIdentityFile(identityFile);				
	}

	sftp.Timeout = 5000;
	sftp.Connect(connInfo.port);
	var files = sftp.GetFileList(FilePath);
	sftp.Close();
}
catch (Exception e)
{
	// Handle exception.
}
finally
{
	if (sftp != null)
	{
		sftp.Close();
	}
}

Constructors

Sftp(string, string)

Initializes a new instance of the Sftp class using the host name and username.

Sftp(string, string, string)

Initializes a new instance of the Sftp class using the host name, username and password.

Properties

ChannelType

Gets the channel type.

Methods

Cancel()

Cancels the operation.

Get(string)

Copies the specified file from the SFTP server.

Get(string, string)

Copies the specified file from the SFTP server to the specified destination directory.

Get(string[])

Copies the specified files from the SFTP server.

Get(string[], string)

Copies the specified files from the SFTP server to the specified destination directory.

GetFileLastModifiedTime(string, StringComparison)

Retrieves the time the file has last been modified.

GetFileList(string)

Retrieves the files in the specified directory.

Mkdir(string)

Creates the specified directory.

Put(string)

Copies the specified file to the SFTP server.

Put(string, string)

Copies the specified file to the specified directory on the SFTP server.

Put(string[])

Copies the specified files to the SFTP server.

Put(string[], string)

Copies the specified files to the specified directory on the SFTP server.