# CopyFiles

Required Frends version: 5.7+

Required .NET version: 8.0

Compatible Agents: Unknown

Source code: <https://github.com/FrendsPlatform/Frends.Smb/tree/main/Frends.Smb.CopyFiles>

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

| Name                      | Description                                                                                                                                                                                                                                     |
| ------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| SourcePath : `PathString` | <p>Source path relative to the share where files will be copied from.</p><p>Can be a directory path or a specific file path.</p><p>Empty means root directory.</p><p><br>Default: <code>-</code><br>Example: <code>documents/reports</code></p> |
| TargetPath : `PathString` | <p>Target path relative to the share where files will be copied to.</p><p>Must be a directory path.</p><p>Empty means root directory.</p><p><br>Default: <code>-</code><br>Example: <code>backup/reports</code></p>                             |
| {% endtab %}              |                                                                                                                                                                                                                                                 |

{% tab title="Parameter: Connection" %}

| Name                   | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| ---------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Server : `String`      | <p>SMB server address or hostname.</p><p><br>Default: <code>-</code><br>Example: <code>127.0.0.1</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                         |
| Share : `String`       | <p>SMB share name to connect to.</p><p><br>Default: <code>-</code><br>Example: <code>testShare</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                           |
| Username : `String`    | <p>Username for SMB authentication.</p><p>This needs to be of format domain\username</p><p><br>Default: <code>-</code><br>Example: <code>WORKGROUP\Administrator</code></p>                                                                                                                                                                                                                                                                                                                                                         |
| 🗝Password : `String`  | <p>Password for the SMB credentials.</p><p><br>Default: <code>-</code><br>Example: <code>Password123</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                     |
| OperatingSystem : `Os` | <p>Defines the operating system of the SMB server.</p><p>Options used to determine correct path separator to use.</p><p>Possible values:</p><ul><li><code>Windows</code>:</li></ul><p>Defines the operating system of the SMB server.</p><p>Options used to determine correct path separator to use.</p><ul><li><code>Linux</code>:</li></ul><p>Defines the operating system of the SMB server.</p><p>Options used to determine correct path separator to use.</p><p><br>Default: <code>2</code><br>Example: <code>Linux</code></p> |
| {% endtab %}           |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |

{% tab title="Parameter: Options" %}

| Name                                        | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| ------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| CreateTargetDirectories : `Boolean`         | <p>If true, creates the target directory and any necessary parent directories if they don't exist.</p><p><br>Default: <code>True</code><br>Example: <code>true</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| IfTargetFileExists : `FileExistsAction`     | <p>Specifies the action to take when a file with the same name already exists in the target location.</p><p>Possible values:</p><ul><li><code>Throw</code>:</li></ul><p>Specifies the action to take when a file with the same name already exists in the target location.</p><ul><li><code>Overwrite</code>:</li></ul><p>Specifies the action to take when a file with the same name already exists in the target location.</p><ul><li><code>Rename</code>:</li></ul><p>Specifies the action to take when a file with the same name already exists in the target location.</p><p><br>Default: <code>1</code><br>Example: <code>Throw</code></p> |
| PreserveDirectoryStructure : `Boolean`      | <p>If true, recreates the source directory structure in the target location.</p><p>If false, all files are moved directly to the target directory without preserving subdirectories.</p><p><br>Default: <code>True</code><br>Example: <code>true</code></p>                                                                                                                                                                                                                                                                                                                                                                                      |
| Recursive : `Boolean`                       | <p>Search for files recursively in subdirectories. Default is true.</p><p><br>Default: <code>True</code><br>Example: <code>true</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| PatternMatchingMode : `PatternMatchingMode` | <p>Define how pattern matching will work.</p><p>Possible values:</p><ul><li><code>Wildcards</code>:</li></ul><p>Define how pattern matching will work.</p><ul><li><code>Regex</code>:</li></ul><p>Define how pattern matching will work.</p><p><br>Default: <code>2</code><br>Example: <code>Regex</code></p>                                                                                                                                                                                                                                                                                                                                    |
| Pattern : `String`                          | <p>Define how pattern matching will work.</p><p><br>Default: <code>-</code><br>Example: <code>Regex</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| ThrowErrorOnFailure : `Boolean`             | <p>Whether to throw an error on failure.</p><p><br>Default: <code>True</code><br>Example: <code>false</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| ErrorMessageOnFailure : `String`            | <p>Overrides the error message on failure.</p><p><br>Default: <code>-</code><br>Example: <code>Custom error message</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| {% endtab %}                                |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |

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

| Name                     | Description                                                                                                                                                                                     |
| ------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Success : `Boolean`      | <p>Indicates if the task completed successfully.<br>Example: <code>true</code></p>                                                                                                              |
| Files : `List<FileItem>` | <p>List of files that were successfully copied, including their source and target paths.<br>Example: <code>\[{SourcePath: "documents\report.txt", TargetPath: "archive\report.txt"}]</code></p> |
| Error : `Error`          | <p>Error that occurred during task execution.<br>Example: <code>object { string Message, Exception AdditionalInfo }</code></p>                                                                  |
| {% endtab %}             |                                                                                                                                                                                                 |

{% tab title="Changelog" %}

## Changelog

### \[2.0.0] - 2026-04-08

#### Added

* New connection parameters that defined what servers Operating System.
* \[Breaking Change] Introduce PathString type that will represent paths with OS specific separators.

### \[1.0.0] - 2025-11-20

#### Added

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