Utilities.FindFirst Method

Applies to TestComplete 15.47, last modified on January 20, 2023
This method is obsolete. See the Remarks section below.

Description

The Utilities.FindFirst method finds the first instance of the file, whose name and path are specified by the Path parameter and whose attributes are specified by the Attr parameter.

A call to the FindFirst method allocates a memory block that is released when you call the FindClose routine. That is, every call to FindFirst must have a corresponding call to FindClose.

Declaration

Utilities.FindFirst(Path, Attr, F)

Path [in]    Required    String    
Attr [in]    Required    Integer    
F [out]    Required    A TSearchRec object    
Result Integer

Applies To

The method is applied to the following object:

Parameters

The method has the following parameters:

Path

Specifies the folder in which the function will perform the search, as well as the file name mask. For instance, to find a .txt file in the C:\Work folder, assign C:\Work\*.txt to the Path parameter.

Attr

The Attr parameter specifies the attributes of the sought-for file. It can be any of the following constants or a combination of them:

Attribute Value Description
faAnyFile 63 Any file.
faReadOnly 1 Read-only file.
faHidden 2 Hidden file.
faSysFile 4 System file.
faVolumeID 8 Volume identifier file.
faDirectory 16 Folder or directory.
faArchive 32 The file that has been changed since the last backup.

F

Stores the specified file attributes and properties.

Note: Before calling the FindFirst function, you should create the TSearchRec object by calling the Utilities.TSearchRec method.

Result Value

If the search is successful, the function stores file attributes and properties to the TSearchRec object and returns 0. If the search is not successful, the function returns a Windows error code.

Remarks

Currently, this method works only in VBScript and DelphiScript scripts.

This method is obsolete. It is supported for backward compatibility only. To search for files, use the aqFileSystem.FindFiles method.

See Also

FindFiles Method
Exists Method
GetFileAttributes Method
Processing Files in a Folder

Highlight search results