MoveFile Activity
Purpose: This activity moves or renames a file to a new location. The file is moved from the source path to the destination path, and the original file is removed. This can be used to move files between directories or to rename files.
Input Properties
The source file path to move. This must be an existing file that is accessible and writable.
Type: string
Required: Yes
Example: "C:\Data\OldName.txt"
The destination file path where the file will be moved. The destination directory will be created if it doesn't exist.
Type: string
Required: Yes
Example: "C:\Archive\NewName.txt"
Output Properties
True if the file was moved 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 already exists, if access is denied, or if an error occurs.
Usage Example
Scenario: Move a file to a new location Configuration: - SourcePath: "C:\Data\Document.txt" - DestinationPath: "C:\Archive\Document.txt" Result: - Success: true (file moved from Data to Archive) Scenario: Rename a file Configuration: - SourcePath: "C:\Data\OldName.txt" - DestinationPath: "C:\Data\NewName.txt" Result: - Success: true (file renamed)
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 moved successfully. Note that if the move fails, the source file remains unchanged.
Important Notes
- The SourcePath must point to an existing file that is accessible and writable
- The destination directory will be created automatically if it doesn't exist
- The source file is removed after a successful move - use CopyFile if you want to preserve the original
- If the destination file already exists, the move will fail
- This activity can be used to rename files by moving them to the same directory with a different name
- Large files may take time to move - consider file size when using this activity
Related Activities
- CopyFile - Copy a file to a new location
- DeleteFile - Delete a file
- CreateDirectory - Create a directory