GetFileLastAccessTime Activity
Purpose: This activity gets the last access timestamp of a file. The last access time indicates when the file was last read or accessed. This is useful for tracking file usage, identifying recently accessed files, or auditing file access patterns.
Input Properties
The file path to get the last access time for. This must be an existing file that is accessible.
Type: string
Required: Yes
Example: "C:\Data\Document.txt"
Output Properties
File last access time as DateTime.
Type: DateTime
Note: Returns the last access time if successful, or DateTime.MinValue if the file path is empty, if the file does not exist, or if an error occurs.
File last access 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 last access time of a file Configuration: - FilePath: "C:\Data\Document.txt" Result: - LastAccessTime: 2024-01-20 10:15:30 (DateTime value) - FormattedLastAccessTime: "2024-01-20 10:15:30" Scenario: Get last access time of non-existent file Configuration: - FilePath: "C:\Data\NonExistent.txt" Result: - LastAccessTime: 0001-01-01 00:00:00 (DateTime.MinValue) - FormattedLastAccessTime: "File not found"
Error Handling
Important: The activity handles errors gracefully:
- If
FilePathis null or empty,LastAccessTimewill beDateTime.MinValueandFormattedLastAccessTimewill be "Invalid path" - If the file does not exist,
LastAccessTimewill beDateTime.MinValueandFormattedLastAccessTimewill be "File not found" - If access is denied (
UnauthorizedAccessException),LastAccessTimewill beDateTime.MinValueandFormattedLastAccessTimewill contain: "Error: Access denied - {exception message}" - If any other exception occurs,
LastAccessTimewill beDateTime.MinValueandFormattedLastAccessTimewill contain: "Error: {exception message}" - The activity does not throw exceptions - errors are indicated in the outputs
Always check the outputs to verify if the last access time was retrieved successfully. Check FormattedLastAccessTime for error messages.
Important Notes
- The file must exist and be accessible to get its last access time
- The LastAccessTime output provides a DateTime value for calculations and comparisons
- The FormattedLastAccessTime output provides a human-readable string in "yyyy-MM-dd HH:mm:ss" format
- Last access time is updated when the file is read or accessed, not just when it's modified
- Use GetFileLastWriteTime to get when the file was last modified
- Use GetFileCreationTime to get when the file was created
Related Activities
- GetFileLastWriteTime - Get last modification time
- GetFileCreationTime - Get creation time
- GetFileSize - Get file size