Sets attribute information for a file.
Public Sub SetAttr( _ ByVal PathName As String, _ ByVal Attributes As FileAttribute _ )
The Attributes argument enumeration values are:
Value | Constant | Description |
---|---|---|
Normal | VbNormal | Normal (default). |
ReadOnly | VbReadOnly | Read-only. |
Hidden | VbHidden | Hidden. |
System | VbSystem | System file. |
Volume | VbVolume | Volume label |
Directory | VbDirectory | Directory or folder. |
Archive | VbArchive | File has changed since last backup. |
Alias | VbAlias | File has a different name. |
Note These enumerations are specified by the Visual Basic language. The names can be used anywhere in your code in place of the actual values.
Exception type | Error number | Condition |
---|---|---|
52 | PathName invalid or does not exist. | |
5 | Attribute type is invalid. |
A run-time error occurs if you try to set the attributes of an open file.
This example uses the SetAttr function to set attributes for a file.
SetAttr("TESTFILE", vbHidden) ' Set hidden attribute. SetAttr("TESTFILE", vbHidden Or vbReadOnly) ' Set hidden and read-only ' attributes.
FileAttr Function | GetAttr Function |