For the complete documentation index, see llms.txt. This page is also available as Markdown.

Copy

Copy files.

Task version: 1.3.0

Required Frends version: 5.5+

Required .NET version: 6.0

Compatible Agents: Crossplatform

Task Parameters

Name
Description

Directory : String

Source directory.

Default: - Example: c:\temp

Pattern : String

Pattern to match for files. The file mask uses regular expressions, but for convenience, it has special handling for * and ? wildcards.

Default: "**\Folder*.xml" Example: test.txt, test*.txt, test?.txt, test.(txt

TargetDirectory : String

Target directory where the found files should be copied to

Default: "d:\backup" Example: d:\backup</code>

Name
Description

UseGivenUserCredentialsForRemoteConnections : Boolean

If set, allows you to give the user credentials to use to delete files on remote hosts.

If not set, the agent service user credentials will be used.

Note: This feature is only possible with Windows agents.

Default: False Example: true

UserName : String

This needs to be of format domain\username

Default: "domain\username" Example: domain\username

🗝Password : String

Password for the used credentials.

Default: - Example: testpwd

PreserveDirectoryStructure : Boolean

If set, will recreate the directory structure from the SourceDirectory under the TargetDirectory for copied files

Default: False Example: true

CreateTargetDirectories : Boolean

If set, will create the target directory if it does not exist,

as well as any sub directories if is set.

Default: True Example: true

IfTargetFileExists : FileExistsAction

What should happen if a file with the same name already exists in the target directory.

* Throw - Throw an error and roll back all transfers

* Overwrite - Overwrites the target file

* Rename - Renames the transferred file by appending a number to the end

Possible values:

  • Throw: What should happen if a file with the same name already exists in the target directory.

* Throw - Throw an error and roll back all transfers

* Overwrite - Overwrites the target file

* Rename - Renames the transferred file by appending a number to the end

  • Overwrite: What should happen if a file with the same name already exists in the target directory.

* Throw - Throw an error and roll back all transfers

* Overwrite - Overwrites the target file

* Rename - Renames the transferred file by appending a number to the end

  • Rename: What should happen if a file with the same name already exists in the target directory.

* Throw - Throw an error and roll back all transfers

* Overwrite - Overwrites the target file

* Rename - Renames the transferred file by appending a number to the end

Default: - Example: FileExistsAction.Overwrite

ThrowErrorOnFail : Boolean

Whether to throw an error on a failure to copy a file.

This option is independent of the option with the value of and will affect handling of all errors during the copy process.

If set to false, task will continue executing despite files failing to copy, otherwise execution will stop at the first failure.

Note: When set to false and is set to , the task will continue copying other files despite a failure.

Behaviour of and will not be affected by this setting.

Default: True Example: true

Task Result

Name
Description

Files : List<FileItem>

List of FileItems including source directory and target directory. Example: [object {SourcePath: C:\test\testfolder\test1.txt, TargetPath: C:\test\moved\test1.txt}, object {SourcePath: C:\test\testfolder\test2.txt, TargetPath: C:\test\moved\test2.txt}]

FailedFiles : List<FailedFileItem>

List of FailedItems including path of the source file and failure exception. This list will always be empty unless is set to false. Example: [object {SourcePath: C:\test\testfolder\test1.txt, Exception: object {Message: Unable to create 'C:\test\moved' directory}}, object {SourcePath: C:\test\testfolder\test2.txt, Exception: object {Message: File 'C:\test\moved\test2.txt' already exists}}]

Task Changelog

Changelog for Task Frends.Files.Copy.

[1.3.0] - 2025-03-19

Changed

  • Update packages: Microsoft.Extensions.FileSystemGlobbing 7.0.0 -> 9.0.3 System.ComponentModel.Annotations 4.7.0 -> 5.0.0 System.DirectoryServices 7.0.0 -> 8.0.0 coverlet.collector 3.1.0 -> 6.0.4 Microsoft.NET.Test.Sdk 16.6.1 -> 17.13.0 MSTest.TestAdapter 2.2.7 -> 3.8.3 MSTest.TestFramework 2.2.8 -> 3.8.3 nunit 3.12.0 -> 4.3.2 NUnit3TestAdapter 3.17.0 -> 5.0.0

[1.2.0] - 2025-04-08

Added

  • New option ThrowErrorOnFail to allow task to continue despite some files failing to copy.

    • Files that failed to copy will be listed in the Result.FailedFiles property.

    • When set to false and IfTargetFileExists is set to Throw, the task will continue copying other files despite an error.

[1.1.0] - 2025-03-13

Fixed

  • Fixed bug where regex patterns were not handled correctly in file matching.

[1.0.2] - 2023-11-27

Changed

  • Documentational changes.

[1.0.1] - 2023-09-21

Fixed

  • Fixed bug with file access. Changed File.Open to use FileAccess.Read, because there's no reason to give more access to the Task.

[1.0.0] - 2023-02-14

Added

  • Initial implementation

Last updated

Was this helpful?