B4X
B4X
Get Filenames in a Remote Directory
Gets the names of files in a remote FTP directory.Chilkat B4X Downloads
Dim success As Boolean = False
' This example requires the Chilkat API to have been previously unlocked.
' See Global Unlock Sample for sample code.
Dim ftp As ChilkatFtp2
ftp.Initialize("ftp")
ftp.Hostname = "ftp.example.com"
ftp.Username = "myLogin"
ftp.Password = "myPassword"
' Use explicit TLS
ftp.AuthTls = True
ftp.Port = 21
' Connect and login to the FTP server.
success = ftp.Connect
If success <> True Then
Log(ftp.LastErrorText)
Return
End If
' Iterate over .txt files.
ftp.ListPattern = "*.txt"
Dim n As Int = ftp.GetDirCount
Log("n = " & n)
Dim i As Int = 0
Do While i < n
Log(i & ": " & ftp.GetFilename(i))
i = i + 1
Loop