aqFileSystem.CheckAttributes Method

Applies to TestComplete 14.91, last modified on July 20, 2021

Description

Use the CheckAttributes method to verify whether the specified file or folder has a certain set of file system attributes. To set or clear the attributes of a file or folder, use the aqFileSystem.ChangeAttributes method.

Declaration

aqFileSystem.CheckAttributes(PathAttribute)

Path [in]    Required    String    
Attribute [in]    Required    Integer    
Result Boolean

Applies To

The method is applied to the following object:

Parameters

The method has the following parameters:

Path

Defines the fully qualified path to the file or folder whose attributes should be checked.

Attribute

An integer number that specifies the attribute(s) to be checked. This parameter can accept one or a combination of the following constants defined in the aqFileSystem object. To combine multiple values, use the bitwise OR operator.

Constant Value Description
faReadOnly 1 A read-only file or folder. Read-only files can be read, but cannot be written to or deleted. Read-only folders cannot be deleted.
faHidden 2 A hidden file or folder. Hidden files and folders are not included in directory listing unless a special setting is applied.
faSystem 4 A system file or folder. System files and folders are part of the operating system or are exclusively used by it.
faVolume 8 A file that is a disk drive volume label.
faDirectory 16 Indicates that a file system object is a folder. You can check this attribute to find out whether the object specified by the Path parameter is a folder or a file.
faArchive 32 An archive file or folder. Archive files and folders are mainly used for backup or removal.
faNormal 128 Indicates that a file or folder does not have any other attributes set. This attribute can only be used alone.
faTemporary 256 A file that is used for temporary storage.
faSparseFile 512 A sparse file. Sparse files are large data files that are mostly empty.
faReparsePoint 1024 A file or folder that has an associated reparse point, or a file that is a link or shortcut file.
faCompressed 2048 A compressed file or folder. Compressed files use special algorithms to decrease their contents. Compressed folders are folders where newly created files do have compressed attribute.
faOffline 4096 A file whose data is physically moved to offline storage. The data of offline files is not immediately available.
faNotContentIndexed 8192 The file is not indexed by the content indexing service.
faEncrypted 16384 An encrypted file or folder. Encrypted files use encryption algorithms to secure their contents. Encrypted folders are folders where newly created files do use encryption.
faVirtual 65536 A virtual file.

Result Value

True if the file or folder has the specified attribute(s), and False otherwise.

Example

The following code snippet checks if a file has both read-only and hidden attributes set:

JavaScript, JScript

if ( aqFileSystem.CheckAttributes("C:\\MyFile.txt", aqFileSystem.faReadOnly | aqFileSystem.faHidden) )
  Log.Message("The file is read-only and hidden.")
else
  Log.Message("The file is not read-only and/or not hidden.");

Python

if aqFileSystem.CheckAttributes("C:\\MyFile.txt", aqFileSystem.faReadOnly | aqFileSystem.faHidden):
  Log.Message("The file is read-only and hidden.")
else:
  Log.Message("The file is not read-only and/or not hidden.")

VBScript

If aqFileSystem.CheckAttributes("C:\MyFile.txt", aqFileSystem.faReadOnly Or aqFileSystem.faHidden) Then
  Log.Message("The file is read-only and hidden.")
Else
  Log.Message("The file is not read-only and/or not hidden.")
End If

DelphiScript

if aqFileSystem.CheckAttributes('C:\MyFile.txt', aqFileSystem.faReadOnly or aqFileSystem.faHidden) then
  Log.Message('The file is read-only and hidden.')
else
  Log.Message('The file is not read-only and/or not hidden.');

C++Script, C#Script

if ( aqFileSystem["CheckAttributes"]("C:\\MyFile.txt", aqFileSystem["faReadOnly"] | aqFileSystem["faHidden"]) )
  Log["Message"]("The file is read-only and hidden.")
else
  Log["Message"]("The file is not read-only and/or not hidden.");

See Also

Working With Files From Scripts
ChangeAttributes Method
Attributes Property
Attributes Property
GetFileAttributes Method
SetFileAttributes Method

Highlight search results