DataFlex
DataFlex
Get Filenames in a Remote Directory
Gets the names of files in a remote FTP directory.Chilkat DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Boolean iSuccess
Handle hoFtp
Integer n
Integer i
String sTemp1
Move False To iSuccess
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
Get Create (RefClass(cComChilkatFtp2)) To hoFtp
If (Not(IsComObjectCreated(hoFtp))) Begin
Send CreateComObject of hoFtp
End
Set ComHostname Of hoFtp To "ftp.example.com"
Set ComUsername Of hoFtp To "myLogin"
Set ComPassword Of hoFtp To "myPassword"
// Use explicit TLS
Set ComAuthTls Of hoFtp To True
Set ComPort Of hoFtp To 21
// Connect and login to the FTP server.
Get ComConnect Of hoFtp To iSuccess
If (iSuccess <> True) Begin
Get ComLastErrorText Of hoFtp To sTemp1
Showln sTemp1
Procedure_Return
End
// Iterate over .txt files.
Set ComListPattern Of hoFtp To "*.txt"
Get ComGetDirCount Of hoFtp To n
Showln "n = " n
Move 0 To i
While (i < n)
Get ComGetFilename Of hoFtp i To sTemp1
Showln i ": " sTemp1
Move (i + 1) To i
Loop
End_Procedure