GetAttributes(Path: String): FileAttributes;
Path - path to a directory, which attributes must be obtained.
The GetAttributes method returns attributes of a directory passed by the Path parameter.
The result of method execution is a combination of values of the FileAttributes enumerable type. Attributes can be checked using the And logical operator.
Sub UserProc(sPath: String);
Var
Attributes: Integer;
Begin
If Directory.Exists(sPath) Then
Attributes := Directory.GetAttributes(sPath);
Debug.WriteLine(Attributes);
If (Attributes And FileAttributes.ReadOnly) <> 0 Then
Debug.WriteLine("The Read-Only attribute is set for directory" );
Else
Debug.WriteLine("The Read-Only attribute is not set for directory" );
End If;
If (Attributes And FileAttributes.Hidden) <> 0 Then
Debug.WriteLine("The Hidden attribute is set for directory" );
Else
Debug.WriteLine("The Hidden attribute is not set for directory" );
End If;
End If;
End Sub UserProc;
On executing the example it is checked if the directory specified in the sPath parameter is present in the file system. If the directory exists, values of its attributes are obtained. Information about state of the Read-Only and Hidden attributes is displayed in the development environment console.
See also: