Attributes Property

Applies to TestComplete 12.60, last modified on September 17, 2018

Description

Use the Attributes property to obtain and check the attributes of the folder to which the aqFolderInfoObj object provides access.

Declaration

aqFolderInfoObj.Attributes

Read-Only Property Integer
aqFolderInfoObj An expression, variable or parameter that specifies a reference to an aqFolderInfo object

Applies To

The property is applied to the following object:

Property Value

An interger value that indicates the attributes of the folder. The method can return one or a combination of constants listed in the following table (these constants are defined in the aqFileSystem object). Multiple values are combined using the bitwise OR operator.

Constant Value Description
faReadOnly 1 A read-only folder.
faHidden 2 A hidden folder.
faSystem 4 A system folder.
faDirectory 16 A folder.
faArchive 32 An archive folder.
faNormal 128 A folder that does not have any other attributes set.
faReparsePoint 1024 A folder that has an associated reparse point.
faCompressed 2048 A compressed folder.
faNotContentIndexed 8192 A folder that is not to be indexed by the content indexing service.
faEncrypted 16384 An encrypted folder.

Remarks

To check if a folder has a specific attribute set, perform the bitwise AND check on the Attribute property value and the value corresponding to the desired attribute (see the example below). Alternatively, you can use the aqFileSystem.CheckAttributes method.

Example

The following example checks if a folder is read-only or not:

JavaScript, JScript

function Test()
{
  var attr = aqFileSystem.GetFolderInfo("C:\\Program Files").Attributes;

  if ((attr & aqFileSystem.faReadOnly) == aqFileSystem.faReadOnly)
    Log.Message("The folder is read-only.")
  else
    Log.Message("The folder is not read-only.");
}

Python

def Test():
  attr = aqFileSystem.GetFolderInfo("C:\\Program Files").Attributes
  if (attr & aqFileSystem.faReadOnly) == aqFileSystem.faReadOnly:
    Log.Message("The folder is read-only.")
  else:
    Log.Message("The folder is not read-only.")

VBScript

Sub Test
  Dim attr
  attr = aqFileSystem.GetFolderInfo("C:\Program Files").Attributes

  If (attr And aqFileSystem.faReadOnly) = aqFileSystem.faReadOnly Then
    Log.Message("The folder is read-only.")
  Else
    Log.Message("The folder is not read-only.")
  End If
End Sub

DelphiScript

procedure Test;
var attr;
begin
  attr := aqFileSystem.GetFolderInfo('C:\Program Files').Attributes;

  if (attr and aqFileSystem.faReadOnly) = aqFileSystem.faReadOnly then
    Log.Message('The folder is read-only.')
  else
    Log.Message('The folder is not read-only.');
end;

C++Script, C#Script

function Test()
{
  var attr = aqFileSystem["GetFolderInfo"]("C:\\Program Files")["Attributes"];

  if ((attr & aqFileSystem["faReadOnly"]) == aqFileSystem["faReadOnly"])
    Log["Message"]("The folder is read-only.")
  else
    Log["Message"]("The folder is not read-only.");
}

The following code checks if a folder has both read-only and system attributes set:

JavaScript, JScript

function Test()
{
  var attr = aqFileSystem.GetFolderInfo("C:\\Windows\\Fonts").Attributes;
  var faReadOnlySystem = aqFileSystem.faReadOnly | aqFileSystem.faSystem;

  if ((attr & faReadOnlySystem) == faReadOnlySystem)
    Log.Message("The folder is read-only and system.")
  else
    Log.Message("The folder is not read-only and/or not system.");
}

Python

def Test1():
  attr = aqFileSystem.GetFolderInfo("C:\\Windows\\Fonts").Attributes
  faReadOnlySystem = aqFileSystem.faReadOnly | aqFileSystem.faSystem
  if (attr & faReadOnlySystem) == faReadOnlySystem:
    Log.Message("The folder is read-only and system.")
  else:
    Log.Message("The folder is not read-only and/or not system.")

VBScript

Sub Test
  Dim attr, faReadOnlySystem
  attr = aqFileSystem.GetFolderInfo("C:\Windows\Fonts").Attributes
  faReadOnlySystem = aqFileSystem.faReadOnly Or aqFileSystem.faSystem

  If (attr And faReadOnlySystem) = faReadOnlySystem Then
    Log.Message("The folder is read-only and system.")
  Else
    Log.Message("The folder is not read-only and/or not system.")
  End If
End Sub

DelphiScript

procedure Test;
var attr, faReadOnlySystem;
begin
  attr := aqFileSystem.GetFolderInfo('C:\Windows\Fonts').Attributes;

  faReadOnlySystem := aqFileSystem.faReadOnly or aqFileSystem.faSystem;
  if (attr and faReadOnlySystem) = faReadOnlySystem then
    Log.Message('The folder is read-only and system.')
  else
    Log.Message('The folder is not read-only and/or not system.');
end;

C++Script, C#Script

function Test()
{
  var attr = aqFileSystem["GetFolderInfo"]("C:\\Windows\\Fonts")["Attributes"];
  var faReadOnlySystem = aqFileSystem["faReadOnly"] | aqFileSystem["faSystem"];

  if ((attr & faReadOnlySystem) == faReadOnlySystem)
    Log["Message"]("The folder is read-only and system.")
  else
    Log["Message"]("The folder is not read-only and/or not system.");
}

See Also

Working With Files From Scripts
aqFileSystem.ChangeAttributes Method
aqFileSystem.CheckAttributes Method
aqFileSystem.GetFolderInfo Method
aqFile.GetFileAttributes Method
aqFile.SetFileAttributes Method

Highlight search results