CreateFile Activity
Purpose: This activity creates an empty file at the specified path. The file is created with zero bytes and can be used as a placeholder or for subsequent write operations. The directory containing the file will be created if it doesn't exist.
Input Properties
The file path to create. This should be a valid file path where the new file will be created.
Type: string
Required: Yes
Example: "C:\Data\NewFile.txt"
Output Properties
True if the file was created successfully, false otherwise.
Type: bool
Note: Returns false if the FilePath is null or empty, if access is denied, if the directory cannot be created, or if an error occurs.
The full path of the created file. If an error occurs, this will contain an error message.
Type: string
Note: Returns the full normalized path of the created file if successful, or an error message (starting with "Error: ") if the operation fails.
Usage Example
Scenario: Create an empty file Configuration: - FilePath: "C:\Data\NewFile.txt" Result: - Success: true - CreatedFilePath: "C:\Data\NewFile.txt" Scenario: Create file in non-existent directory Configuration: - FilePath: "C:\NewFolder\NewFile.txt" Result: - Success: true - CreatedFilePath: "C:\NewFolder\NewFile.txt" (directory created automatically)
Error Handling
Important: The activity handles errors gracefully:
- If
FilePathis null or empty,Successwill befalseandCreatedFilePathwill be empty - If access is denied (
UnauthorizedAccessException),Successwill befalseandCreatedFilePathwill contain: "Error: Access denied - {exception message}" - If the directory cannot be found (
DirectoryNotFoundException),Successwill befalseandCreatedFilePathwill contain: "Error: Directory not found - {exception message}" - If an IO error occurs (
IOException),Successwill befalseandCreatedFilePathwill contain: "Error: IO error - {exception message}" - If any other exception occurs,
Successwill befalseandCreatedFilePathwill contain: "Error: {exception message}"
Always check the Success output and review the CreatedFilePath for error messages if the operation fails.
Important Notes
- The directory containing the file will be created automatically if it doesn't exist
- The created file is empty (0 bytes) - use other activities to write content to it
- If the file already exists, it will be overwritten with an empty file
- The CreatedFilePath contains the full normalized path, which may differ from the input path
- Ensure the location has write permissions and sufficient disk space
Related Activities
- DeleteFile - Delete a file
- CopyFile - Copy a file
- CreateDirectory - Create a directory