Rebex

Skip to content, Skip to navigation




Sample: GetPut - SFTP Download/Upload

A utility for uploading and downloading files using SFTP.

C#

// create Sftp object, connect and log in 
Sftp sftp = new Sftp();
sftp.Connect (hostname);
sftp.Login (username, password);

// download file and display number of bytes transferred 
long bytes = sftp.GetFile (remotePath, localPath);
Console.WriteLine ("Transferred {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)

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

' disconnect 
sftp.Disconnect()

See also: