GetFileNameWithoutExtension Activity
Purpose: This activity extracts the filename without the extension from a full file path. It returns just the filename portion, excluding both the directory path and the file extension. This is useful when you need the base name of a file.
Input Properties
The file path to extract the filename without extension from.
Type: string
Required: Yes
Example: "C:\Data\Documents\Report.txt"
Output Properties
The filename without extension (e.g., 'file' from 'file.txt').
Type: string
Note: Returns the filename without 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 without extension Configuration: - FilePath: "C:\Data\Documents\Report.txt" Result: - FileNameWithoutExtension: "Report" Scenario: Extract from file with multiple dots Configuration: - FilePath: "C:\Data\File.backup.txt" Result: - FileNameWithoutExtension: "File.backup" (only last extension removed)
Error Handling
Important: The activity handles errors gracefully:
- If
FilePathis null or empty,FileNameWithoutExtensionwill be set to an empty string - If the path contains invalid characters (
ArgumentException),FileNameWithoutExtensionwill contain: "Error: Invalid path - {exception message}" - If any other exception occurs,
FileNameWithoutExtensionwill contain: "Error: {exception message}" - The activity does not throw exceptions - errors are indicated in the
FileNameWithoutExtensionoutput
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
- Only the last extension is removed (e.g., "File.backup.txt" becomes "File.backup")
- Works with both absolute paths (e.g., "C:\Data\File.txt") and relative paths (e.g., "Data\File.txt")
- Use GetFileName if you need the filename with extension
- Use GetExtension if you only need the file extension
Related Activities
- GetFileName - Get filename with extension
- GetExtension - Get file extension
- GetDirectoryName - Get directory path from file path