# FileAttr

The **FileAttr** object is provided to make it easier to deal with file attributes. Rather than dealing with attributes as a string of characters, or a number, it provides properties for each attribute that can be set or queried independently. You can create a new **FileAttr** object using the [**FSUtil**](fsutil)**.NewFileAttr** method. **FileAttr** objects are also returned by properties of the [**Format**](format) and [**Item**](item) objects.

Each attribute is represented by two properties; a single character (e.g. **a**) and its full name (e.g. **archive**). Each property returns **True** if the attribute is set, and **False** if not. For **FileAttr** objects you create yourself, you can also set the value of these properties (and then, for example, apply the attributes to a file using the [**File**](file)**.SetAttr** method).

&#x20;

| Property Name          | Return Type | Description                                                                                                                                                                                                                                                                                      |
| ---------------------- | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| _\<default value>_     | _string_    | Returns a string representing the attributes that are set (similar to the format displayed in the _Attr_ column in the file display).                                                                                                                                                            |
| <p>a<br>archive</p>    | _bool_      | A file or directory that has changes which need archiving. The A bit is usually set on new or modifies files, and may then be cleared by backup software after it has added the changes to a backup.                                                                                             |
| <p>c<br>compressed</p> | _bool_      | A file or directory that is compressed. For a file, all of the data in the file is compressed. For a directory, compression is the default for newly created files and subdirectories.                                                                                                           |
| <p>e<br>encrypted</p>  | _bool_      | A file or directory that is encrypted. For a file, all data streams in the file are encrypted. For a directory, encryption is the default for newly created files and subdirectories.                                                                                                            |
| <p>h<br>hidden</p>     | _bool_      | The file or directory is hidden. It is not included in an ordinary directory listing.                                                                                                                                                                                                            |
| <p>i<br>nonindexed</p> | _bool_      | The file or directory is not to be indexed by the content indexing service.                                                                                                                                                                                                                      |
| <p>o<br>offline</p>    | _bool_      | The data of a file is not available immediately. This attribute indicates that the file data is physically moved to offline storage. This attribute is used by Remote Storage, which is the hierarchical storage management software. Applications should not arbitrarily change this attribute. |
| <p>p<br>pinned</p>     | _bool_      | The data of the file is to be kept available at all times; it should not be offloaded to offline storage.                                                                                                                                                                                        |
| <p>r<br>readonly</p>   | _bool_      | A file that is read-only. Applications can read the file, but cannot write to it or delete it. This attribute is not honored on directories.                                                                                                                                                     |
| <p>s<br>system</p>     | _bool_      | A file or directory that the operating system uses a part of, or uses exclusively.                                                                                                                                                                                                               |

| Method Name | **Arguments**                         | Return Type | Description                                                                                                                                                      |
| ----------- | ------------------------------------- | ----------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Assign      | \*object:\***FileAttr\\** or _string_ | none        | Assigns a new set of attributes to this object. You can pass another **FileAttr** object, or a string (e.g. _"hsr"_).                                            |
| AttrName    | _string_                              | _string_    | Given a single character representing an attribute (e.g. _"a"_) this method returns the name of the attribute in the user's current language (e.g. _"Archive"_). |
| Clear       | \*object:\***FileAttr\\** or _string_ | none        | Clears (turns off) the specified attributes in this object. You can pass another **FileAttr** object, or a string representing the attributes to turn off.       |
| Set         | \*object:\***FileAttr\\** or _string_ | none        | Sets (turns on) the specified attributes in this object. You can pass another **FileAttr** object, or a string representing the attributes to turn on.           |
| ToString    | none                                  | none        | Returns a string representing the attributes that are set (similar to the format displayed in the _Attr_ column in the file display).                            |
