Method ListDirectoryAsync
ListDirectoryAsync(string, CancellationToken)
Lists a directory, without . and ... Entries arrive in batches as the server sends them; names that cannot be
file names in one directory (empty, or with a /) are left out.
public IAsyncEnumerable<SftpFileInfo> ListDirectoryAsync(string path, CancellationToken cancellationToken = default)
Parameters
pathstringcancellationTokenCancellationToken
Returns
Remarks
Names are UTF-8 in SFTP version 3 as OpenSSH uses it; a name that is not valid UTF-8 (a legacy encoding on the server) is listed with U+FFFD in place of the bytes it cannot decode, so FullPath cannot open it. A listing stops with an error (ProtocolError) after 1,000,000 entries or 1,000 empty batches in a row, so a hostile server cannot make it run forever.