CitectVBA Programming Reference > CitectVBA Function Reference > File I/O Functions > GetAttr

GetAttr

GetAttr function returns an Integer representing the attribute settings of a file, directory, or volume.

The required File argument must be valid string expression representing a valid file name. File may contain a DOS path structure including directory or folder names, and a drive letter.

To determine which attributes are set, use the AND operator to perform a bitwise comparison of the value returned by the GetAttr function and the value of the individual file attribute you want. If the result is not zero, that attribute is set for the named file. For example, the return value of the following AND expression is zero if the Archive attribute is not set:

Const AttrArchive = 32
Result = GetAttr(FileName) And AttrArchive ' A nonzero value is returned if the Archive attribute is set.

Syntax

GetAttr(File)

File:

A string or expression that can represent a valid file name, and may include a DOS path structure including directory or folder names, and a drive letter.

Return Value

Returns an Integer number indicating the sum Attribute value of a file, directory, or folder for the Fileargument, where:

Related Functions

Get # | Line Input # | Print # | Put #

Example

Dim intAttrVal
' Assume file TESTFILE has hidden attribute set.
intAttrVal = GetAttr("TESTFILE.txt") ' Returns 2.
' Assume file TESTFILE has hidden and read-only attributes set.
intAttrVal = GetAttr("TESTFILE.txt") Returns 3.
' Assume MYDIR is a directory or folder.
intAttrVal = GetAttr("MYDIR") ' Returns 16.