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

SourcePath

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"

DestinationPath

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

Success

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 SourcePath or DestinationPath is null or empty, Success will be false
  • If the source file does not exist (FileNotFoundException), Success will be false
  • If access is denied (UnauthorizedAccessException), Success will be false
  • If an IO error occurs (IOException), Success will be false
  • If any other exception occurs, Success will be false
  • The activity does not throw exceptions - errors are indicated by the Success output

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