CopyFile Activity
Purpose: This activity copies a file to a new location. The source file remains unchanged, and a copy is created at the destination path. This is useful for backing up files, creating duplicates, or moving files to different locations while preserving the original.
Input Properties
The source file path to copy. This must be an existing file that is accessible and readable.
Type: string
Required: Yes
Example: "C:\Data\Source.txt"
The destination file path where the copy will be created. The destination directory will be created if it doesn't exist.
Type: string
Required: Yes
Example: "C:\Backup\Source.txt"
True to overwrite existing files; false to fail if destination exists.
Type: bool
Default: false
Note: If set to false and the destination file already exists, the copy operation will fail.
Output Properties
True if the file was copied successfully, false otherwise.
Type: bool
Note: Returns false if the source or destination path is null or empty, if the source file does not exist, if the destination file exists and Overwrite is false, if access is denied, or if an error occurs.
Usage Example
Scenario: Copy a file to a backup location Configuration: - SourcePath: "C:\Data\Document.txt" - DestinationPath: "C:\Backup\Document.txt" - Overwrite: false Result: - Success: true Scenario: Copy with overwrite enabled Configuration: - SourcePath: "C:\Data\Report.xlsx" - DestinationPath: "C:\Archive\Report.xlsx" - Overwrite: true Result: - Success: true (even if destination exists)
Error Handling
Important: The activity handles errors gracefully:
- If
SourcePathorDestinationPathis null or empty,Successwill befalse - If the source file does not exist (
FileNotFoundException),Successwill befalse - If access is denied (
UnauthorizedAccessException),Successwill befalse - If an IO error occurs (
IOException),Successwill befalse - If any other exception occurs,
Successwill befalse - The activity does not throw exceptions - errors are indicated by the
Successoutput
Always check the Success output to verify if the file was copied successfully.
Important Notes
- The SourcePath must point to an existing file that is accessible and readable
- The destination directory will be created automatically if it doesn't exist
- If Overwrite is
falseand the destination file exists, the operation will fail - The source file remains unchanged after copying
- Large files may take time to copy - consider file size when using this activity
- Ensure the destination location has sufficient disk space
Related Activities
- MoveFile - Move a file to a new location
- DeleteFile - Delete a file
- CreateDirectory - Create a directory