' Technical support: support@smartftp.com

Module Module1

    Dim objSSH As sfFTPLib.SSHConnectionClass
    Dim objSFTP As sfFTPLib.SFTPConnectionClass

    Sub SFTPTest()
        objSFTP = objSSH.CreateSFTPConnection()
				'Dim fileLogger As sfFTPLib.FileLogger
				'fileLogger = objSFTP.SetFileLogger()
				'fileLogger.File = "sftp.log"

        Dim strCurrentDirectory As System.String
        strCurrentDirectory = objSFTP.RealPath(".")

        ' Read Directory
        Dim objDirectory As sfFTPLib.FTPItemsClass
        objDirectory = objSFTP.ReadDirectory(strCurrentDirectory)
        Dim objItem As sfFTPLib.FTPItem
        For Each objItem In objDirectory
            System.Console.WriteLine("Type={0}; Name={1}; Size={2}", objItem.Type, objItem.Name, objItem.Size)

        ' Download File
        Dim startPosition As System.UInt64
        startPosition = 0
        Dim endPosition As System.UInt64
        endPosition = 0

        ' Note: The first argument is the full path to the source file
        objSFTP.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", objSFTP.LastTransferBytes)
        System.Console.WriteLine("LastTransferTime = {0} s", objSFTP.LastTransferTime)
        System.Console.WriteLine("LastTransferSpeed = {0} B/s", objSFTP.LastTransferSpeed)

    End Sub

    Sub Main()
        Dim objGlobal As sfFTPLib.[Global]
        'objGlobal = CreateObject("sfFTPLib.Global")
        objGlobal = 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

        'objFTP = CreateObject("sfFTPLib.SSHConnection")
        objSSH = New sfFTPLib.SSHConnection

        ' Favorite settings
        objSSH.Host = "localhost"
        objSSH.Port = 22
        objSSH.Username = "username"
        objSSH.Password = "password"

        ' Proxy settings
        objSSH.Proxy.Type = sfFTPLib.ProxyType.ftpProxyTypeNone

				'Dim fileLogger As sfFTPLib.FileLogger
				'fileLogger = objSSH.SetFileLogger()
				'fileLogger.File = "ssh.log"


        objSSH = Nothing
    End Sub
End Module