GetPut SFTP Download/Upload (.NET Compact Framework)

GetPut SFTP Download/Upload (.NET Compact Framework)

Sample utility for uploading and downloading files using SFTP.

C#

// create Sftp object, connect to the server and login
Sftp sftp = new Sftp();
sftp.Connect(hostname);
sftp.Login(username, password);

// set transfer type to binary
sftp.TransferType = SftpTransferType.Binary;

// upload file and display number of bytes transferred
long bytes = sftp.PutFile(localPath, remotePath);
Console.WriteLine("Transfered {0} bytes.", bytes);

// disconnect
sftp.Disconnect();

VB.NET

' create Sftp object, connect and log in
Dim sftp As New Sftp()
sftp.Connect(hostname)
sftp.Login(username, password)

' set transfer type to binary
sftp.TransferType = SftpTransferType.Binary

' upload file and display number of bytes transferred
Dim bytes As Long = sftp.PutFile(localPath, remotePath)
Console.WriteLine("Transfered {0} bytes.", bytes)

' disconnect
sftp.Disconnect()

Included in

See also: