GetFileName Activity
Purpose: This activity extracts the filename from a full file path. It returns just the filename portion, including the extension, without the directory path. This is useful for getting the name of a file when you only have the full path.
Input Properties
The full file path to extract the filename from.
Type: string
Required: Yes
Example: "C:\Data\Documents\Report.txt"
Output Properties
The filename extracted from the path (e.g., 'file.txt' from 'C:\folder\file.txt').
Type: string
Note: Returns the filename with extension if successful, an empty string if FilePath is null or empty, or an error message (starting with "Error: ") if an error occurs.
Usage Example
Scenario: Extract filename from full path Configuration: - FilePath: "C:\Data\Documents\Report.txt" Result: - FileName: "Report.txt" Scenario: Extract filename from relative path Configuration: - FilePath: "Data\Files\Document.pdf" Result: - FileName: "Document.pdf"
Error Handling
Important: The activity handles errors gracefully:
- If
FilePathis null or empty,FileNamewill be set to an empty string - If the path contains invalid characters (
ArgumentException),FileNamewill contain: "Error: Invalid path - {exception message}" - If any other exception occurs,
FileNamewill contain: "Error: {exception message}" - The activity does not throw exceptions - errors are indicated in the
FileNameoutput
Note: This activity does not require the file to exist - it only extracts the filename from the path string.
Important Notes
- This activity does not require the file to exist - it only processes the path string
- The filename includes the file extension (e.g., "Report.txt")
- Works with both absolute paths (e.g., "C:\Data\File.txt") and relative paths (e.g., "Data\File.txt")
- Use GetFileNameWithoutExtension if you need the filename without the extension
- Use GetExtension if you only need the file extension
Related Activities
- GetFileNameWithoutExtension - Get filename without extension
- GetExtension - Get file extension
- GetDirectoryName - Get directory path from file path