Skip to content

SSH.SFTPDirectory

Andrew Lambert edited this page Jul 9, 2023 · 23 revisions

SSH.SFTPDirectory

Class Declaration

 Protected Class SFTPDirectory

Remarks

This class represents a directory listing operation over SFTP.

Create a new instance and then read the CurrentName, CurrentType, CurrentLength, etc. properties to get metadata on the current item in the listing, then call ReadNextEntry() to load the next item.

If the SuppressVirtualEntries property is set to True and the directory is empty then the CurrentType property will be SFTPEntryType.Unknown and the CurrentIndex property will be -1. If SuppressVirtualEntries is False then an empty directory will appear to contain two subdirectories.

Methods

Properties

Example

This example collects the names of all files and subdirectories in a remote directory:

  Dim session As SSH.Session = SSH.Connect("ssh://user:password@public.example.com/")
  Dim sftp As New SSH.SFTPSession(session)
  Dim names() As String
  Dim lister As SSH.SFTPDirectory = sftp.ListDirectory("/path/to/dir/")
  
  Do
    names.Append(lister.CurrentName)
  Loop Until Not lister.ReadNextEntry()

  lister.Close()

See also

Clone this wiki locally