sftp/Module1.vb
' Technical support: support@smartftp.com
Module Module1
	Dim sshConnection As sfFTPLib.SSHConnection
	Dim sftpConnection As sfFTPLib.SFTPConnection
	Sub SFTPTest()
		sftpConnection = sshConnection.CreateSFTPConnection()
		'Dim fileLogger = sftpConnection.SetFileLogger()
		'fileLogger.File = "sftp.log"
		sftpConnection.Connect()
		Dim currentDirectory = sftpConnection.RealPath(".")
		' Read Directory
		Dim directoryItems As sfFTPLib.FTPItems = sftpConnection.ReadDirectory(currentDirectory)
		Dim item As sfFTPLib.FTPItem
		For Each item In directoryItems
			If item.Type = sfFTPLib.ItemType.ftpItemTypeRegularFile Then
				System.Console.WriteLine("Type={0}; Name={1}; Size={2}", item.Type, item.Name, item.Size)
			Else
				System.Console.WriteLine("Type={0}; Name={1}", item.Type, item.Name)
			End If
		Next
		' Download File
		Dim startPosition As ULong = 0
		Dim endPosition As ULong = ULong.MaxValue
		' Note: The first argument is the full path to the source file
		sftpConnection.DownloadFileEx("/History.txt", "History.txt", sfFTPLib.DataTransferType.ftpDataTransferTypeImage, startPosition, endPosition, sfFTPLib.DownloadFlags.ftpDownloadFlagReadBeyondEnd, Nothing)
		System.Console.WriteLine("DownloadFile() successful.")
		System.Console.WriteLine("LastTransferBytes = {0} B", sftpConnection.LastTransferBytes)
		System.Console.WriteLine("LastTransferTime = {0} s", sftpConnection.LastTransferTime)
		System.Console.WriteLine("LastTransferSpeed = {0} B/s", sftpConnection.LastTransferSpeed)
		' Upload file
		'sftpConnection.UploadFileEx("c:\test.dat", "/remotefolder/test.dat", sfFTPLib.DataTransferType.ftpDataTransferTypeImage, startPosition, Nothing)
	End Sub
	Sub Main()
		Dim ftplibGlobal = New sfFTPLib.[Global]
		' Load License
		' If LoadLicense is not called a trial license is automatically obtained from the activation server. The FTP Library uses WinHTTP to access
		' the activation server at www.smartftp.com (TLS, port 443). Ensure that your application is not blocked by any firewall.
		' TODO: insert the provided serial after the purchase of a license
		'ftplibGlobal.LoadLicense("XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX")
		sshConnection = New sfFTPLib.SSHConnection
		' Favorite settings
		sshConnection.Host = "localhost"
		sshConnection.Port = 22
		sshConnection.Username = "username"
		sshConnection.Password = "password"
		' Proxy settings
		'sshConnection.Proxy.Type = sfFTPLib.ProxyType.ftpProxyTypeNone
		'Dim fileLogger As sfFTPLib.FileLogger
		'fileLogger = sshConnection.SetFileLogger()
		'fileLogger.File = "ssh.log"
		sshConnection.Connect()
		SFTPTest()
		sshConnection.Disconnect()
		sshConnection = Nothing
	End Sub
End Module