DeleteFile Activity

Purpose: This activity deletes a file from the file system. The file is permanently removed and cannot be recovered through normal means. Use this activity with caution, especially for important files.

Input Properties

FilePath

The file path to delete. This must be an existing file that is accessible and writable.

Type: string

Required: Yes

Example: "C:\Data\OldFile.txt"

Output Properties

Success

True if the file was deleted successfully, false otherwise.

Type: bool

Note: Returns false if the FilePath is null or empty, if the file does not exist, if access is denied, if the file is locked by another process, or if an error occurs.

Usage Example

Scenario: Delete a file

Configuration:
- FilePath: "C:\Data\TempFile.txt"

Result:
- Success: true (file deleted)

Scenario: Delete non-existent file

Configuration:
- FilePath: "C:\Data\NonExistent.txt"

Result:
- Success: false (file doesn't exist)

Error Handling

Important: The activity handles errors gracefully:

  • If FilePath is null or empty, Success will be false
  • If the file does not exist (FileNotFoundException), Success will be false
  • If access is denied (UnauthorizedAccessException), Success will be false
  • If the file is locked by another process (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 deleted successfully.

Important Notes

  • WARNING: This operation is permanent - deleted files cannot be easily recovered
  • The file must not be locked by another process (e.g., open in an application) - close all handles to the file before deleting
  • If the file does not exist, the operation will fail (returns false)
  • Ensure you have write permissions to the file and its directory
  • Consider using CopyFile to create a backup before deleting important files
  • Deleted files are not moved to the Recycle Bin - they are permanently removed

Related Activities