GetFileAttributes Activity
Purpose: This activity gets the file attributes of a file. File attributes include properties like ReadOnly, Hidden, System, Archive, and others. The activity returns both a human-readable comma-separated string and a numeric value representing the attributes.
Input Properties
The file path to get attributes for. This must be an existing file that is accessible.
Type: string
Required: Yes
Example: "C:\Data\Document.txt"
Output Properties
File attributes as a comma-separated string. Contains attribute names like "ReadOnly", "Hidden", "Archive", etc., or "Normal" if no special attributes are set.
Type: string
Note: Returns a comma-separated list of attribute names 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.
Example: "ReadOnly, Archive" or "Normal"
File attributes as a numeric value. This is the raw numeric representation of the file attributes.
Type: int
Note: Returns the numeric value of attributes if successful, or 0 if the file path is empty, if the file does not exist, or if an error occurs.
Usage Example
Scenario: Get attributes of a file Configuration: - FilePath: "C:\Data\Document.txt" Result: - Attributes: "ReadOnly, Archive" - AttributesValue: 33 Scenario: Get attributes of normal file Configuration: - FilePath: "C:\Data\NormalFile.txt" Result: - Attributes: "Normal" - AttributesValue: 128
Error Handling
Important: The activity handles errors gracefully:
- If
FilePathis null or empty,Attributeswill be "Invalid path" andAttributesValuewill be 0 - If the file does not exist,
Attributeswill be "File not found" andAttributesValuewill be 0 - If access is denied (
UnauthorizedAccessException),Attributeswill contain: "Error: Access denied - {exception message}" andAttributesValuewill be 0 - If any other exception occurs,
Attributeswill contain: "Error: {exception message}" andAttributesValuewill be 0 - The activity does not throw exceptions - errors are indicated in the outputs
Always check the Attributes output to verify if the operation succeeded. Check for error messages in the Attributes string.
Supported File Attributes
ReadOnly- File is read-only and cannot be modifiedHidden- File is hidden from normal directory listingsSystem- File is a system fileArchive- File is marked for backup or removalTemporary- File is a temporary fileOffline- File data is not available offlineNotContentIndexed- File content should not be indexedEncrypted- File is encryptedCompressed- File is compressedNormal- File has no special attributes
Important Notes
- The file must exist and be accessible to get its attributes
- The Attributes output provides a human-readable list of attribute names
- The AttributesValue output provides the raw numeric value for programmatic use
- Multiple attributes can be set on a single file - they will be listed as comma-separated values
- Use SetFileAttributes to modify file attributes
Related Activities
- SetFileAttributes - Set file attributes
- GetFileSize - Get file size
- GetFileCreationTime - Get file creation time