> For the complete documentation index, see [llms.txt](https://docs.frends.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.frends.com/tasks/tasks/sftp/listfiles.md).

# ListFiles

List files from set destination directory with optional file mask through SFTP connection.

Task version: 3.0.0

Required Frends version: 5.5+

Required .NET version: 6.0

Compatible Agents: Crossplatform

Source code: <https://github.com/FrendsPlatform/Frends.SFTP/tree/main/Frends.SFTP.ListFiles>

## Task Parameters

{% tabs %}
{% tab title="Input" %}

| Name                              | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| --------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Directory : `String`              | <p>Directory on the server.</p><p><br>Default: <code>/</code><br>Example: <code>/directory/test/</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| FileMask : `String`               | <p>Pattern to match (Optional).</p><p><br>Default: <code>-</code><br>Example: <code>\*.txt</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| IncludeType : `IncludeType`       | <p>Types to include in the directory listing.</p><p>Possible values:</p><ul><li><code>File</code>: Types to include in the directory listing.</li><li><code>Directory</code>: Types to include in the directory listing.</li><li><code>Both</code>: Types to include in the directory listing.</li></ul><p><br>Default: <code>File</code><br>Example: <code>IncludeType.File</code></p>                                                                                                                                                                                                                                                                                                                                                                                                           |
| IncludeSubdirectories : `Boolean` | <p>Include subdirectories?</p><p><br>Default: <code>-</code><br>Example: <code>true</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| FileEncoding : `FileEncoding`     | <p>Encoding for the file names.</p><p>By selecting 'Other' you can use any encoding.</p><p>Possible values:</p><ul><li><code>UTF8</code>: Encoding for the file names.</li></ul><p>By selecting 'Other' you can use any encoding.</p><ul><li><code>ANSI</code>: Encoding for the file names.</li></ul><p>By selecting 'Other' you can use any encoding.</p><ul><li><code>ASCII</code>: Encoding for the file names.</li></ul><p>By selecting 'Other' you can use any encoding.</p><ul><li><code>WINDOWS1252</code>: Encoding for the file names.</li></ul><p>By selecting 'Other' you can use any encoding.</p><ul><li><code>Other</code>: Other enables users to add other encoding options as string.</li></ul><p><br>Default: <code>ANSI</code><br>Example: <code>FileEncoding.ANSI</code></p> |
| EnableBom : `Boolean`             | <p>Additional option for UTF-8 encoding to enable bom.</p><p><br>Default: <code>False</code><br>Example: <code>true</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| EncodingInString : `String`       | <p>File encoding to be used.</p><p>Encoding don't support any unicode encoding. It only support the code page encodings.</p><p>A partial list of possible encodings: <https://en.wikipedia.org/wiki/Windows_code_page#List>.</p><p><br>Default: <code>-</code><br>Example: <code>utf-8</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| {% endtab %}                      |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |

{% tab title="Connection" %}

| Name                                             | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| ------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| ConnectionTimeout : `Int32`                      | <p>The lenght of time, in seconds, until the connection times out.</p><p>You can use value -1 to indicate that the connection does not time out.</p><p>Default value is 60 seconds.</p><p><br>Default: <code>60</code><br>Example: <code>60</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| MaxExecutionTimeout : `Int32`                    | <p>The maximum length of time, in seconds, for the entire SFTP operation to complete.</p><p>This includes connection establishment, file listing, and all subdirectory traversal.</p><p>Acts as a safety timeout in addition to ConnectionTimeout and OperationTimeout settings.</p><p>You can use value 0 to indicate that the operation does not time out.</p><p><br>Default: <code>0</code><br>Example: <code>600</code></p>                                                                                                                                                                                                                                                                                                                                                                |
| Address : `String`                               | <p>SFTP host address</p><p><br>Default: <code>-</code><br>Example: <code>localhost</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| Port : `Int32`                                   | <p>Port number to use in the connection to the server.</p><p><br>Default: <code>22</code><br>Example: <code>22</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| Authentication : `AuthenticationType`            | <p>Selection for authentication type</p><p>Possible values:</p><ul><li><code>UsernamePassword</code>: Authentication type which uses username and password.</li><li><code>UsernamePrivateKeyFile</code>: Authentication type which uses username and private key file</li><li><code>UsernamePrivateKeyString</code>: Authentication type which uses username and private key as a string.</li><li><code>UsernamePasswordPrivateKeyFile</code>: Authentication type which uses username, password and private key file.</li><li><code>UsernamePasswordPrivateKeyString</code>: Authentication type which uses username, password and private key as a string.</li></ul><p><br>Default: <code>-</code><br>Example: <code>AuthenticationType.UsernamePassword</code></p>                          |
| Username : `String`                              | <p>Username to use for authentication to the server. Note that the file endpoint only supports</p><p>username for remote shares and the username must be in the format DOMAIN\Username.</p><p><br>Default: <code>-</code><br>Example: <code>foo</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| 🗝Password : `String`                            | <p>Password to use in the authentication to the server.</p><p><br>Default: <code>-</code><br>Example: <code>pass</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| PrivateKeyFile : `String`                        | <p>Full path to private key file. Supported private key formats: OpenSSH and ssh.com.</p><p>PuTTY keys can be converted with puttygen.exe application.</p><p>1. Load your key file into puttygen.exe</p><p>2. Conversion > Export OpenSSH key (not the "force new file format" option)</p><p><br>Default: <code>-</code><br>Example: <code>C:\path\to\private\key</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                   |
| 🗝PrivateKeyString : `String`                    | <p>Private key as a string, supported private key formats: OpenSSH and ssh.com.</p><p>PuTTY keys can be converted with puttygen.exe application.</p><p>1. Load your key file into puttygen.exe</p><p>2. Conversion > Export OpenSSH key (not the "force new file format" option)</p><p><br>Default: <code>-</code><br>Example: <code>-----BEGIN RSA PRIVATE KEY----- Fqxq2jbSKyb0a+oW96Tjoif3Kcb5zZ0FiQyiHgQozLXrecjdUwjWuedkDoZMxwG5 bxpOnxZ/88tDzYCtCPcYCPRF8BNueUsZO8/tztTra+4NgVd/omXHG5bqb7iMB4dc ... OX7Q/wO4lqOlFhLtRnSL0cfuhRmt59pM75Zd+euX5tv9jmCj+AQT/kiBoMhNrDGk N2gTujnH7HCr/afSBeL3xnYcEmeCQTxTPZofBjPC+TPd9g7MntSGBeU/Fstv0jbg -----END RSA PRIVATE KEY-----</code></p>                                                                                                          |
| 🗝PrivateKeyPassphrase : `String`                | <p>Passphrase for the private key file.</p><p><br>Default: <code>-</code><br>Example: <code>passphrase</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| ServerFingerPrint : `String`                     | <p>Fingerprint of the SFTP server. When using "Username-Password"</p><p>authentication it is recommended to use server fingerprint in</p><p>order to be sure of the server you are connecting.</p><p><br>Default: <code>-</code><br>Example: <code>MD5: '41:76:EA:65:62:6E:D3:68:DC:41:9A:F2:F2:20:69:9D' SHA256: 'FBQn5eyoxpAl33Ly0gyScCGAqZeMVsfY7qss3KOM/hY='</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                    |
| HostKeyAlgorithm : `HostKeyAlgorithms`           | <p>Host key algorithm to use when connecting to server.</p><p>Default value is Any which doesn't force the task to use</p><p>specific algorithm.</p><p>Possible values:</p><ul><li><code>Any</code>: The algorithm is negotiated with the server.</li></ul><p>The task will use ed25519 as default.</p><ul><li><code>RSA</code>: Force the ssh-rsa host key algorithm.</li><li><code>Ed25519</code>: Force the ssh-ed25519 host key algorithm.</li><li><code>nistp256</code>: Force the ecdsa-sha2-nistp256 host key algorithm.</li><li><code>nistp384</code>: Force the ecdsa-sha2-nistp384 host key algorithm.</li><li><code>nistp521</code>: Force the ecdsa-sha2-nistp521 host key algorithm.</li></ul><p><br>Default: <code>Any</code><br>Example: <code>HostKeyAlgorithms.RSA</code></p> |
| UseKeyboardInteractiveAuthentication : `Boolean` | <p>Enable if the server uses keyboard-interactive authentication method.</p><p><br>Default: <code>False</code><br>Example: <code>false</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| PromptAndResponse : `PromptResponse[]`           | <p>Responses for the server prompts when using Keyboard Interactive authentication method.</p><p><br>Default: <code>-</code><br>Example: <code>-</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| {% endtab %}                                     |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| {% endtabs %}                                    |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |

## Task Result

| Name                     | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| ------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| FileCount : `Int32`      | <p>Count of files found from the directory.<br>Example: <code>2</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| Files : `List<FileItem>` | <p>List of file items found from the directory.<br>Example: <code>\[ { "FullPath": "/upload/down/test2.txt", "IsDirectory": false, "IsFile": true, "Length": 54, "Name": "test2.txt", "LastWriteTimeUtc": "2022-11-07T12:17:36Z", "LastAccessTimeUtc": "2022-11-07T12:17:37Z", "LastWriteTime": "2022-11-07T14:17:36+02:00", "LastAccessTime": "2022-11-07T14:17:37+02:00" }, { "FullPath": "/upload/down/test1.txt", "IsDirectory": false, "IsFile": true, "Length": 0, "Name": "test1.txt", "LastWriteTimeUtc": "2022-11-07T12:17:36Z", "LastAccessTimeUtc": "2022-11-07T12:17:37Z", "LastWriteTime": "2022-11-07T14:17:36+02:00", "LastAccessTime": "2022-11-07T14:17:37+02:00" }, ]</code></p> |

## Task Changelog

Changelog for Task Frends.SFTP.ListFiles.

### \[3.0.0] - 2026-01-27

#### Changed

**Breaking changes!**

* Updated dependency SSH.NET to the newest version 2025.1.0.
* Drop DSS support

### \[2.7.0] - 2026-01-13

#### Fixed

* Operation timeout is now using the Connection.ConnectionTimeout parameter.

### \[2.6.0] - 2025-12-16

#### Added

* Added MaxExecutionTimeout parameter (default: 0 = no limit) to set a maximum time limit for the entire SFTP list operation.

### \[2.5.0] - 2025-04-09

#### Changed

* Clarified that the encoding parameter is used for the file name encoding.

### \[2.4.0] - 2025-01-03

#### Fixed

* Fixed issue with ConnectionInfoBuilder having static properties for connection and input parameters which lead to Task not being thread safe.

### \[2.3.0] - 2024-08-19

#### Updated

* Updated Renci.SshNet library to version 2024.1.0.

### \[2.2.0] - 2023-12-21

#### Updated

* \[Breaking] Updated dependency SSH.NET to the newest version 2023.0.0.

#### Changed

* Changed connection info builder to create the connection info as it's done in DownloadFiles.
* \[Breaking] Changed PrivateKeyFilePassphrase parameter to PrivateKeyPassphrase and enabled it when PrivateKeyString was used.

### \[2.0.1] - 2022-12-01

#### Updated

* Updated dependency Microsoft.Extensions.DependencyInjection to the newest version.

### \[2.0.0] - 2022-11-09

#### Added

* Added keyboard authentication method
* \[Breaking] Added parameter for keyboard authentication
* Modified result Task to return object instead of list
* Added result attribute FileCount
* Added more tests e.g. Serverfingerprint tests
* Added System.Text.CodePages NuGet to the project
* Added ConnectionInfoBuilder
* Added HostKeyAlgorithm enum

### \[1.0.2] - 2022-06-28

#### Changed

* Reconstructed the Task to be similar to other SFTP tasks
* Implemented more authentication options
* Added timeout option
* Added File name encoding options
* Updated tests

### \[1.0.1] - 2022-06-20

#### Changed

* SSH.NET version upgrade from 2020.0.1 to 2020.0.2

### \[1.0.0] - 2022-04-01

#### Added

* Initial implementation


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.frends.com/tasks/tasks/sftp/listfiles.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
