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
FilePathis null or empty,Successwill befalse - If the file does not exist (
FileNotFoundException),Successwill befalse - If access is denied (
UnauthorizedAccessException),Successwill befalse - If the file is locked by another process (
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 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
- CopyFile - Create a backup before deleting
- MoveFile - Move a file instead of deleting
- DeleteDirectory - Delete a directory