GetFileCreationTime Activity

Purpose: This activity gets the creation timestamp of a file. The creation time indicates when the file was originally created on the file system. This is useful for tracking file age, organizing files by creation date, or auditing file operations.

Input Properties

FilePath

The file path to get the creation time for. This must be an existing file that is accessible.

Type: string

Required: Yes

Example: "C:\Data\Document.txt"

Output Properties

CreationTime

File creation time as DateTime.

Type: DateTime

Note: Returns the creation time if successful, or DateTime.MinValue if the file path is empty, if the file does not exist, or if an error occurs.

FormattedCreationTime

File creation time as formatted string.

Type: string

Note: Returns a formatted string like "2024-01-15 14:30:45" if successful, "Invalid path" if FilePath is empty, "File not found" if the file doesn't exist, or an error message (starting with "Error: ") if an error occurs.

Usage Example

Scenario: Get creation time of a file

Configuration:
- FilePath: "C:\Data\Document.txt"

Result:
- CreationTime: 2024-01-15 14:30:45 (DateTime value)
- FormattedCreationTime: "2024-01-15 14:30:45"

Scenario: Get creation time of non-existent file

Configuration:
- FilePath: "C:\Data\NonExistent.txt"

Result:
- CreationTime: 0001-01-01 00:00:00 (DateTime.MinValue)
- FormattedCreationTime: "File not found"

Error Handling

Important: The activity handles errors gracefully:

  • If FilePath is null or empty, CreationTime will be DateTime.MinValue and FormattedCreationTime will be "Invalid path"
  • If the file does not exist, CreationTime will be DateTime.MinValue and FormattedCreationTime will be "File not found"
  • If access is denied (UnauthorizedAccessException), CreationTime will be DateTime.MinValue and FormattedCreationTime will contain: "Error: Access denied - {exception message}"
  • If any other exception occurs, CreationTime will be DateTime.MinValue and FormattedCreationTime will contain: "Error: {exception message}"
  • The activity does not throw exceptions - errors are indicated in the outputs

Always check the outputs to verify if the creation time was retrieved successfully. Check FormattedCreationTime for error messages.

Important Notes

  • The file must exist and be accessible to get its creation time
  • The CreationTime output provides a DateTime value for calculations and comparisons
  • The FormattedCreationTime output provides a human-readable string in "yyyy-MM-dd HH:mm:ss" format
  • Creation time is different from last write time - creation time is when the file was first created, while last write time is when it was last modified
  • Use GetFileLastWriteTime to get when the file was last modified
  • Use GetFileLastAccessTime to get when the file was last accessed

Related Activities