GETATTR

GETATTR(pathname)

Returns the attributes of a given file or directory (Integer).


pathnameThe full pathname of the file you want to examine (String).

REMARKS
* The value returned corresponds to the vbFileAttribute enumeration.
* The value returned is a sum of the following values:
* 0 = vbNormal.
* 1 = vbReadOnly.
* 2 = vbHidden.
* 4 = vbSystem. Not available on Macintosh.
* 16 = vbDirectory.
* 32 = vbArchive. Not available on Macintosh.
* 64 = vbAlias. Only on Macintosh.
* The "pathname" may include a directory and drive.
* The easiest way to find out which attributes are set is to use the AND operator to perform a bitwise comparison of the value and the value and the attribute.
* You can use the DIR function to check if a file or directory exists.
* You can use the FILEATTR function to return the file mode of an open file.
* You can use the SETATTR statement to define the attributes of a file or directory.
* The equivalent .NET function is Microsoft.VisualBasic.FileSystem.GetAttr
* For the Microsoft documentation refer to learn.microsoft.com

'test if the file only has the hidden attribute
If (GetAttr("C:\temp\myfile.docx") = 2) Then

'test for read only using bitwise comparison
If ( GetAttr("C:\temp\myfile.xlam") And (vbFileAttribute.vbReadOnly) ) Then
End If

'test for both read only and hidden using bitwise comparison
If ( GetAttr("C:\temp\myfile.xlam") And (vbReadOnly + vbHidden) ) Then
End If

© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited Top