GetAttr Function |
No
GetAttr(pathname)
pathname
Use: Required
Data Type: String
File and optional path name.
An integer representing the attributes set for the file or folder, being the sum of the following constant values:
Constant | Value | Description |
---|---|---|
vbNormal | 0 | Normal |
vbReadOnly | 1 | Read-only |
vbHidden | 2 | Hidden |
vbSystem | 4 | System |
vbDirectory | 16 | Directory or folder |
vbArchive | 32 | File has changed since last backup |
Determines which attributes have been set for a file, directory, or folder.
pathname may optionally include a directory or folder name and a drive letter, including a network drive. pathname can also follow the UNC format of //machine_name/drive.
You can check if a particular attribute has been set by performing a bit-wise comparison of the GetAttr return value and the value of the attribute constant using the And operator. A nonzero result means that the particular attribute has been set; conversely, a zero value indicates that the attribute has not been set. For example:
If GetAttr(myfile.txt) And vbReadOnly = 0 then Msgbox "The file is Read-Write" Else MsgBox "The file is Read-Only" End If
The file attribute constants are defined to be globally available for use within your projects.