Utilities.FileOpen Method

Applies to TestComplete 15.10, last modified on December 01, 2021
This method is obsolete. See the Remarks section below.

Description

The Utilities.FileOpen method opens the file whose name and path are specified by the FileName parameter and returns the handle for the opened file. If an error occurs when opening the file, the function returns -1.

Declaration

Utilities.FileOpen(FileName, Mode)

FileName [in]    Required    String    
Mode [in]    Required    Integer    
Result Integer

Applies To

The method is applied to the following object:

Parameters

The method has the following parameters:

FileName

Specifies the full name of the file to be opened.

Mode

The Mode parameter specifies the access and sharing modes of the file to be opened. It is a combination of one of the access and one of the sharing constants listed below. To combine the access and sharing constants, use the or operator:

Access Constants
Constant Value Description
fmOpenRead 0 Open the file for reading.
fmOpenWrite 1 Open the file for writing.
fmOpenReadWrite 2 Open the file for both reading and writing.
Sharing Constants
Constant Value Description
fmShareCompat 0 This mode is provided for compatibility with MS DOS. If you open the file in this mode, other users or processes also can open the file in any mode.
fmShareExclusive 16 Provides exclusive access to the file. Other users or processes cannot open the file.
fmShareDenyWrite 32 Other users or processes cannot open the file for writing. They can only read from the file.
fmShareDenyRead 48 Other users or processes cannot open the file for reading. They can only write to the file.
fmShareDenyNone 64 Other users or processes have full access to the file.

Result Value

The handle of the opened file.

For DelphiScript: The resultant file handle can be used only by file management routines that are provided by the Utilities object (for example, by FileWrite or FileRead). It cannot be used with file management routines provided by the DelphiScript engine (these functions are listed in the DelphiScript Routines topic).

Remarks

This method is obsolete. It is supported for backward compatibility only. To open a file for reading or writing, use the aqFile.OpenBinaryFile, aqFile.OpenTextFile, aqFileInfo.OpenBinaryFile or aqFileInfo.OpenTextFile method.

See Also

OpenBinaryFile Method
OpenTextFile Method
OpenBinaryFile Method
OpenTextFile Method
Cursor Property
Cursor Property
Close Method
Close Method
FindFiles Method
Exists Method

Highlight search results