Session.EnumerateRemoteFiles Method

Recursively enumerates remote files.



public IEnumerable<RemoteFileInfo> EnumerateRemoteFiles(
    string path,
    string mask,
    EnumerationOptions options
Public Function EnumerateRemoteFiles(
     path As String,
     mask As String,
     options As EnumerationOptions
) As IEnumerable(Of RemoteFileInfo)


Name Description
string path Full path to root remote directory to start enumeration in.
string mask Windows wildcard to filter files.1 To select all files, use null.
EnumerationOptions options Enumeration options set.
Possible values are:
EnumerationOptions.None – Enumerate matching files only. Do not recurse.
EnumerationOptions.AllDirectories – Recurse into subdirectories.
EnumerationOptions.MatchDirectories – Enumerate also matching directories. Cannot be combined with EnumerationOptions.EnumerateDirectories.
EnumerationOptions.EnumerateDirectories – Enumerate also all directories. Must be used with EnumerationOptions.AllDirectories. Cannot be combined with EnumerationOptions.MatchDirectories.

Return Value

An enumerable collection of the RemoteFileInfo instances representing matched files (and directories, if EnumerationOptions.MatchDirectories or EnumerationOptions.EnumerateDirectories option is used).


Exception Condition
InvalidOperationException Session is not opened.
ArgumentException Invalid combination of options.
SessionLocalException Error communicating with
See the exception documentation for details.
SessionRemoteException Session has failed.
Enumeration of files has failed.
See the exception documentation for details.
TimeoutException Timeout waiting for to respond.



References to this directory (.) and parent directory (..) are never enumerated.

Use RemoteFileInfo.FullName to retrieve a full path to the enumerated file or directory.

Errors, when listing subfolders, are silently ignored. You can use the Session.Failed event to capture these errors.

The method cannot be used via COM interface (i.e. from VBScript, JScript or VBA).


Real-Life Examples

  1. The Windows wildcard supports * and ? only.Back

Last modified: by martin