aqFile.ReadWholeTextFile Method

Applies to TestComplete 14.93, last modified on October 12, 2021

Description

The ReadWholeTextFile method opens the specified file in text mode using the given encoding type and returns the file contents as a single string.

Declaration

aqFile.ReadWholeTextFile(Path, TextCodingType)

Path [in]    Required    String    
TextCodingType [in]    Required    Integer    
Result String

Applies To

The method is applied to the following object:

Parameters

The method has the following parameters:

Path

Specifies the fully-qualified path to the desired file.

TextCodingType

An integer value that defines a file’s character encoding. You can specify one of the possible integer values directly, or you can use the appropriate constant:

Constant Value Description
aqFile.ctANSI 20 ANSI
aqFile.ctUnicode 21 Unicode (UTF-16)
aqFile.ctUTF8 22 UTF8

Result Value

A string that contains the entire contents of the file.

Example

The code below demonstrates how you can read file content and post it to the test log.

JavaScript, JScript

function ReadWholeFile(AFileName)
{
  var s;
  s = aqFile.ReadWholeTextFile(AFileName, aqFile.ctANSI);
  Log.Message("File entire contents:");
  Log.Message(s);
}

Python

def ReadWholeFile(AFileName):
  s = aqFile.ReadWholeTextFile(AFileName, aqFile.ctANSI)
  Log.Message("File entire contents:")
  Log.Message(s)

VBScript

Sub ReadWholeFile(AFileName)
  s = aqFile.ReadWholeTextFile(AFileName, aqFile.ctANSI)
  Log.Message("File entire contents:")
  Log.Message(s)
End Sub

DelphiScript

procedure ReadWholeFile(AFileName);
var s: String;
begin
  s := aqFile.ReadWholeTextFile(AFileName, aqFile.ctANSI);
  Log.Message('File entire contents:');
  Log.Message(s);
end;

C++Script, C#Script

function ReadWholeFile(AFileName)
{
  var s;
  s = aqFile["ReadWholeTextFile"](AFileName, aqFile["ctANSI"]);
  Log["Message"]("File entire contents:");
  Log["Message"](s);
}

See Also

Working With Files From Scripts
WriteToTextFile Method
OpenTextFile Method
ReadWholeTextFile Method

Highlight search results