I need to get a list of subdirectories in an SFTP directory, so I need to know the filetypes of all the items in the directory to find which are directories. I set up my CURLSMBS instance exactly the same as shown in the “CURLS ftp directory listing with CURLSFileInfoMBS” example.

If I don’t use

d.OptionCustomRequest = "MLSD"

the program has a hard crash when executing

Dim files() As CURLSFileInfoMBS = d.FileInfos

If I do set it for MLSD, the program doesn’t crash, but the array of FileInfos is empty.

The documentation for CURLSFileInfoMBS says

If you use OptionWildcard, you find after the transfer all CURLFileInfoMBS objects for all the files/folders found.

but the documentation for OptionWIldcardMatch says it is only available for FTP, not SFTP. So how to get a list of directories using SFTP?

SFTP and CURLSFileInfoMBS don’t work together.

Just do a listing with OptionDirListOnly=true of the directory URL.
The output is then the output of directly listing.

OutputData from a listing with OptionDirListOnly=true is a simple string list of all directory items, without any information as to which items are files and which items are directories. How can I get the item type info without using CURLSFileInfoMBS?

You may have missed to try examples.

So path of URL ends with / and you skip OptionDirListOnly property. Then you get the list?

Yes, I am using your examples. I just hadn’t noticed that a “d” at the start of file permissions means it’s a directory, which is the information I was looking for, thanks!