Back to product page

ListNames function


Lists the file and folder names in a directory on the server.

Type

A Long value. If successful, 0 is returned, otherwise error as specified here

Syntax

  • C
long Sftp_ListNames(void *Sftp, char *RemotePath);
The ListNames(void *Sftp,char *RemotePath) syntax has these parts:
void *SftpHandle of the created Sftp instance.
char *RemotePathFull path to a file on the server.

Remarks

The ListNames function will send a request to the server to retrieve just the names of files and directories in the given path. Once the server sends data, the ListItems callback will be invoked (possibly more than once!) containing a list of files sent by the server, each one on a separate line, split by a CRLF sequence. If the item is a directory, wodSFTP will append / (slash) to the end of it. The ListItems event is fired more than once if the total number of files is too large to be handled by one SFTP packet. So you should wait for the Done callback before declaring the listing as finished.

Once completed, the Done callback will be called. If no error occurs, the ErrorCode argument in the Done callback will be set to 0 (zero). If an error occurrs, the ErrorCode will hold the number of the error and ErrorText will contain a description of the error.

No wildcards can be used with the RemotePath argument. The RFC protocol specification for SFTP does not allow them.

To retrieve a full listing of files/directories on a given path (including size, permissions, dates...) you should use the ListDir function. To retrieve the structure of a directory in a ready-parsed array of WIN32_FIND_DATA structures, you should use the ListAttributes function.

Platforms

Windows