wwSFTP::FtpListFiles

Gets a file listing for a remote folder and returns a collection of objects with the following properties:

  • Name
  • Length
  • FileAttribute (16 - directory, 128 - file)
  • LastWriteTime
  • IsDirectory

You can use this method instead of aFtpDir() of the base class, which is not supported by this SFPT implementation.

Make sure a connection is open by calling FtpConnect() before using this and other low level operations.

o.FtpListFiles(lcPath)

Return Value

Collection of file objects or null

Parameters

lcPath
The path on the server to return files for. Pass an empty string for the current active folder. Note it doesn't work with wildcards or filespecs only folder names.

Example

loFtp = CREATEOBJECT("wwFtp")
loFtp.cFtpServer = "west-wind.com"
loFtp.nFtpPort = 23
loFtp.cUsername = "tester"
loFtp.cPassword = "password"

loFtp.FtpConnect()

*** List files in active folder
loFiles = loFtp.FtpListFiles("")  && or: "/subfolder" or "subfolder2" (relative)
loFtp.FtpClose()

this.AssertTrue(!ISNULL(loFiles),loFtp.cErrorMsg)

FOR EACH loFile IN loFiles FOXOBJECT
  ? loFile.Name + " - " +;
    TRANSFORM(loFile.Length) + " - " +;
    TRANSFORM(loFile.FileAttribute) + " -  " +;
    TRANSFORM(loFile.LastWriteTime)
ENDFOR

See also:

Class wwSFTP

© West Wind Technologies, 2023 • Updated: 12/09/20
Comment or report problem with topic