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

FilePath

The file path to extract the filename without extension from.

Type: string

Required: Yes

Example: "C:\Data\Documents\Report.txt"

Output Properties

FileNameWithoutExtension

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 FilePath is null or empty, FileNameWithoutExtension will be set to an empty string
  • If the path contains invalid characters (ArgumentException), FileNameWithoutExtension will contain: "Error: Invalid path - {exception message}"
  • If any other exception occurs, FileNameWithoutExtension will contain: "Error: {exception message}"
  • The activity does not throw exceptions - errors are indicated in the FileNameWithoutExtension output

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