ftp/Module1.bas

' Technical support: support@smartftp.com

Attribute VB_Name = "Module1"
Option Explicit

Public objFTP As sfFTPLib.FTPConnectionSTA
Public objGlobal As sfFTPLib.Global

' With events
'Dim WithEvents objFTP As FTPConnectionSTA

Sub Main()
	' VB6 binding howto
	' http://kandkconsulting.tripod.com/VB/Tutorials/vb_binding_tutorial.htm

 	'Early Binding "Dual Interface"
	'Note: Force the compiler to use the dual interface if available
	Set objGlobal = CreateObject("sfFTPLib.Global")

	' Uncomment to load key from string
	'objGlobal.LoadLicense("XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX")

	'Early Binding "Dual Interface"
	'Note: Force the compiler to use the dual interface if available
	Set objFTP = CreateObject("sfFTPLib.FTPConnectionSTA")

	'Early Binding "Mid Level"
	'Note: The compiler may use the dual interface
	'Set objFTP = New sfFTPLib.FTPConnectionSTA
    
	objFTP.Host = "ftp.smartftp.com"
	objFTP.Port = 21
	objFTP.Protocol = ftpProtocolSSLExplicit
	objFTP.Username = "anonymous"
	objFTP.Password = "test@test.com"
	objFTP.Passive = True
	objFTP.LogFile.File = "VB6Demo.log"

	objFTP.Connect()
	MsgBox ("Connected.")
	objFTP.ChangeDirectory("/SmartFTP")
	MsgBox ("ChangeDirectory() successful.")
	' Read Directory
	Dim objDirectory As sfFTPLib.FTPItems
	Set objDirectory = objFTP.ReadDirectory()
	Dim objItem As sfFTPLib.FTPItem
	Dim strList
	For Each objItem In objDirectory
		strList = strList & "Type=" & objItem.Type & "; Name=" & objItem.Name & "; Size=" & objItem.SizeLo & Chr(13) & Chr(10)
	Next
	MsgBox (strList)

	' Download File
	Dim nRestartLo : nRestartLo = 0
	Dim nRestartHi : nRestartHi = 0

	Dim strMsg
	objFTP.DownloadFile("History.txt", "History.txt", nRestartLo, nRestartHi)
	strMsg = "DownloadFile() successful." & Chr(13) & Chr(10)
	strMsg = strMsg & "LastTransferBytes = " & objFTP.LastTransferBytesLo & " B" & Chr(13) & Chr(10)
	strMsg = strMsg & "LastTransferTime = " & objFTP.LastTransferTime & " s" & Chr(13) & Chr(10)
	strMsg = strMsg & "LastTransferSpeed = " & objFTP.LastTransferSpeed & " B/s"
	MsgBox (strMsg)
End Sub