# MoveFile

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.MoveFile>

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

| Name                                       | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| ------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Directory : `String`                       | <p>Source directory.</p><p><br>Default: <code>/</code><br>Example: <code>/source</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| Pattern : `String`                         | <p>Pattern to match for files. The file mask uses regular expressions, but for convenience, it has special handling for \* and ? wildcards.</p><p><br>Default: <code>\*.xml</code><br>Example: <code>/destination</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| TargetDirectory : `String`                 | <p>Target directory where the found files should be copied to.</p><p><br>Default: <code>/</code><br>Example: <code>/destination</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| IfTargetFileExists : `FileExistsOperation` | <p>Operation for if the transferred file exists in destination.</p><p>Possible values:</p><ul><li><code>Throw</code>:</li></ul><p>Operation for if the transferred file exists in destination.</p><ul><li><code>Rename</code>:</li></ul><p>Operation for if the transferred file exists in destination.</p><ul><li><code>Overwrite</code>:</li></ul><p>Operation for if the transferred file exists in destination.</p><p><br>Default: <code>0</code><br>Example: <code>FileExistsOperation.Throw</code></p>                                                                                                                                                                                                                                                                                                                                                  |
| CreateTargetDirectories : `Boolean`        | <p>Enables the Task to create the target directories.</p><p><br>Default: <code>True</code><br>Example: <code>true</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| FileEncoding : `FileEncoding`              | <p>Encoding for the read content.</p><p>By selecting 'Other' you can use any encoding.</p><p>Possible values:</p><ul><li><code>UTF8</code>:</li></ul><p>Encoding for the read content.</p><p>By selecting 'Other' you can use any encoding.</p><ul><li><code>ANSI</code>:</li></ul><p>Encoding for the read content.</p><p>By selecting 'Other' you can use any encoding.</p><ul><li><code>ASCII</code>:</li></ul><p>Encoding for the read content.</p><p>By selecting 'Other' you can use any encoding.</p><ul><li><code>WINDOWS1252</code>:</li></ul><p>Encoding for the read content.</p><p>By selecting 'Other' you can use any encoding.</p><ul><li><code>Other</code>:</li></ul><p>Encoding for the read content.</p><p>By selecting 'Other' you can use any encoding.</p><p><br>Default: <code>1</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="Parameter: 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>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| KeepAliveInterval : `Int32`                      | <p>The keep-alive interval in milliseconds. Interval the client send keep-alive packages to the host.</p><p>You can use value -1 to disable the keep-alive.</p><p><br>Default: <code>-1</code><br>Example: <code>-1</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>:</li></ul><p>Selection for authentication type</p><ul><li><code>UsernamePrivateKeyFile</code>:</li></ul><p>Selection for authentication type</p><ul><li><code>UsernamePrivateKeyString</code>:</li></ul><p>Selection for authentication type</p><ul><li><code>UsernamePasswordPrivateKeyFile</code>:</li></ul><p>Selection for authentication type</p><ul><li><code>UsernamePasswordPrivateKeyString</code>:</li></ul><p>Selection for authentication type</p><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>:</li></ul><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><ul><li><code>RSA</code>:</li></ul><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><ul><li><code>Ed25519</code>:</li></ul><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><ul><li><code>nistp256</code>:</li></ul><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><ul><li><code>nistp384</code>:</li></ul><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><ul><li><code>nistp521</code>:</li></ul><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><br>Default: <code>0</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>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| BufferSize : `UInt32`                            | <p>Integer value of used buffer size as KB.</p><p>Default value is 32 KB.</p><p><br>Default: <code>32</code><br>Example: <code>32</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| {% endtab %}                                     |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |

{% tab title="Result: Result" %}

| Name                     | Description                                                                                                                                                                                                                                                          |
| ------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Files : `List<FileItem>` | <p>List of FileItem objects with source path and target path attributes.<br>Example: <code>\[object { SourcePath: /source/test1.txt, TargetPath: /destination/test1.txt }, object { SourcePath: /source/test2.txt, TargetPath: /destination/test2.txt } ]</code></p> |
| Message : `String`       | <p>Message consisting information on the transfer.<br>Example: <code>Successfully moved 2 files to /destination/.</code></p>                                                                                                                                         |
| {% endtab %}             |                                                                                                                                                                                                                                                                      |

{% tab title="Changelog" %}

## Changelog

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

#### Changed

**Breaking changes!**

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

### \[1.5.0] - 2026-01-16

#### Fixed

* Task can now create nested target directories.

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

#### Fixed

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

### \[1.3.0] - 2025-01-10

#### Fixed

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

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

#### Updated

* Updated Renci.SshNet library to version 2024.1.0.

#### Added

* Added more tests.

### \[1.1.0] - 2023-12-22

#### 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.

#### Added

* Added FileEncoding for file names.

### \[1.0.0] - 2023-22-05

#### Added

* Initial implementation
  {% endtab %}
  {% endtabs %}
