aqFile.ReadWholeTextFile Method

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

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(PathTextCodingType)

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

One of the following constants that specify the file’s character encoding:

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
aqFile.WriteToTextFile Method
aqFile.OpenTextFile Method
ReadWholeTextFile Method

Highlight search results