Get Attrpathname

This function returns an integer (a member of the FileAttribute enumeration) representing the attributes of a file, directory, or folder, according to Table 5.

Table 5: The FileAttribute Enumeration

Constant

Value

Attribute

Normal

0

Normal

ReadOnly

1

Read-only

Hidden

2

Hidden

System

4

System

Volume

8

Volume label

Directory

16

Directory or folder

Archive

32

File has changed since last backup

To determine which attributes are set, use the AND operator to perform a bitwise comparison of the value returned by the GetAttrQ function and the value of one or more attributes. If the result is not zero, that attribute is set for the named file. For example, to find out if a file is read-only, use a statement such as the following:

Result = GetAttr(FName) And FileAttribute.ReadOnly

If the file Fname has its read-only attribute set, Result will be 1. If not, Result will be 0, regardless of the values of any other attributes. To find out whether a file has its archive attribute set, then the statement

Result = GetAttr(FName) And FileAttribute.Archive will assign the value 32 to the Result variable.

If the file has both its archive and read-only attributes set, the GetAttr() function will return the value 33. However, you must AND this value with the appropriate constant to find out whether a certain attribute is set.

0 0

Post a comment