Web Connection
Class wwSFTP
Gravatar is a globally recognized avatar based on your email address. Class wwSFTP
  John Henn
  All
  Jan 30, 2020 @ 12:02pm

In sftp list files - how to tell a file from a directory?

Gravatar is a globally recognized avatar based on your email address. re: Class wwSFTP
  Rick Strahl
  John Henn
  Jan 30, 2020 @ 01:52pm

You can check the File Attribute for a value of 16. I've also added a new property IsDirectory for future releases.

https://webconnection.west-wind.com/docs/_4tc1eh7o5.htm

For now this code works:

loFtp = CREATEOBJECT("wwFtp")
loFtp.cFtpServer = "test.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
  IF loFileAttribute == 16
     ? "It's a directory"
  ELSE
     ? "It's a file"
  ENDIF
ENDFOR

+++ Rick ---

© 1996-2020