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

FilePath

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

Attributes

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"

AttributesValue

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 FilePath is null or empty, Attributes will be "Invalid path" and AttributesValue will be 0
  • If the file does not exist, Attributes will be "File not found" and AttributesValue will be 0
  • If access is denied (UnauthorizedAccessException), Attributes will contain: "Error: Access denied - {exception message}" and AttributesValue will be 0
  • If any other exception occurs, Attributes will contain: "Error: {exception message}" and AttributesValue will 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

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