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.
Namespace: Microsoft.VisualBasic
Module: FileSystem
Assembly: Microsoft Visual Basic .NET Runtime (in MicrosoftVisualBasic.dll)
FileAttr Function | GetAttr Function |