Xbase++
Xbase++
Get Filenames in a Remote Directory
Gets the names of files in a remote FTP directory.Chilkat Xbase++ Downloads
LOCAL nSuccess
LOCAL oFtp
LOCAL n
LOCAL i
nSuccess := 0
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
oFtp := CreateObject("Chilkat.Ftp2")
oFtp:Hostname := "ftp.example.com"
oFtp:Username := "myLogin"
oFtp:Password := "myPassword"
// Use explicit TLS
oFtp:AuthTls := 1
oFtp:Port := 21
// Connect and login to the FTP server.
nSuccess := oFtp:Connect()
IF (nSuccess != 1)
? oFtp:LastErrorText
oFtp:destroy()
RETURN
ENDIF
// Iterate over .txt files.
oFtp:ListPattern := "*.txt"
n := oFtp:GetDirCount()
? "n = " + Str(n)
i := 0
DO WHILE i < n
? Str(i) + ": " + oFtp:GetFilename(i)
i := i + 1
ENDDO
oFtp:destroy()