' Technical support: support@smartftp.com

Option Explicit On 

Module Module1

    Dim objFTP As sfFTPLib.FTPConnectionMTAClass

    Sub Main()
        Dim objGlobal As sfFTPLib.[Global]
        objGlobal = New sfFTPLib.[Global]
        ' Load License Key
        ' Uncomment to load license

        objFTP = New sfFTPLib.FTPConnectionMTA

        ' Attach the event handler
        AddHandler objFTP.OnDisconnect, AddressOf OnDisconnect

        ' Favorite settings
        objFTP.Host = "ftp.smartftp.com"
        objFTP.Port = 21
        objFTP.Protocol = sfFTPLib.Protocol.ftpProtocolSSLExplicit
        objFTP.Username = "anonymous"
        objFTP.Password = "test@test.com"
        objFTP.MLST = True
        objFTP.Passive = True

		' Proxy settings
		'objFTP.Proxy.Type = sfFTPLib.ProxyType.ftpProxyTypeNone
		'objFTP.FTPProxy.Type = sfFTPLib.FTPProxyType.ftpFTPProxyTypeNone

		Dim fileLogger As sfFTPLib.fileLogger
		fileLogger = objFTP.SetFileLogger()
		fileLogger.File = "VBDemo.log"

        Dim objDirectory As sfFTPLib.FTPItemsClass
        objDirectory = objFTP.ReadDirectory()
        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 ULong
		startPosition = 0
		Dim endPosition As ULong
		endPosition = ULong.MaxValue
		objFTP.DownloadFileEx("This is a DEMO server.txt", "This is a DEMO server.txt", startPosition, endPosition, Nothing)

		System.Console.WriteLine("DownloadFile() successful.")
		System.Console.WriteLine("LastTransferBytes = {0} B", objFTP.LastTransferBytes)
		System.Console.WriteLine("LastTransferTime = {0} s", objFTP.LastTransferTime)
        System.Console.WriteLine("LastTransferSpeed = {0} B/s", objFTP.LastTransferSpeed)

		' Upload file
		'objFTP.UploadFileEx("c:\test.dat", "test.dat", startPosition, Nothing);


		objFTP = Nothing

	End Sub

    Sub OnDisconnect()
    End Sub

End Module