ReadWholeTextFile Method

Applies to TestComplete 14.10, last modified on June 5, 2019

Description

The ReadWholeTextFile method assumes that the file related to the aqFileInfoObj object is a text file. This method reads the whole contents of the file and returns it as a string.

Declaration

aqFileInfoObj.ReadWholeTextFile(TextCodingType)

aqFileInfoObj An expression, variable or parameter that specifies a reference to an aqFileInfo object
TextCodingType [in]    Required    Integer    
Result String

Applies To

The method is applied to the following object:

Parameters

The method has the following parameter:

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 reads file contents and posts them to the test log.

JavaScript, JScript

function ReadWholeFile(AFileName)
{
  var s;

  // Obtains information about the file
  s = aqFileSystem.GetFileInfo(AFileName).ReadWholeTextFile(aqFile.ctANSI);

  // Posts the file contents to the test log
  Log.Message("File entire contents:");
  Log.Message(s);
}

Python

def ReadWholeFile(AFileName):  
  # Obtains information about the file
  s = aqFileSystem.GetFileInfo(AFileName).ReadWholeTextFile(aqFile.ctANSI)
  # Posts the file contents to the test log
  Log.Message("File entire contents:")
  Log.Message(s)

VBScript

Sub ReadWholeFile(AFileName)

  ' Obtains information about the file
  s = aqFileSystem.GetFileInfo(AFileName).ReadWholeTextFile(aqFile.ctANSI)

  ' Posts the file contents to the test log
  Log.Message("File entire contents:")
  Log.Message(s)
End Sub

DelphiScript

procedure ReadWholeFile(AFileName);
var s: String;
begin

  // Obtains information about the file
  s := aqFileSystem.GetFileInfo(AFileName).ReadWholeTextFile(aqFile.ctANSI);

  // Posts the file contents to the test log
  Log.Message('File entire contents:');
  Log.Message(s);
end;

C++Script, C#Script

function ReadWholeFile(AFileName)
{
  var s;

  // Obtains information about the file
  s = aqFileSystem["GetFileInfo"](AFileName)["ReadWholeTextFile"](aqFile["ctANSI"]);

  // Posts the file contents to the test log
  Log["Message"]("File entire contents:");
  Log["Message"](s);
}

See Also

Working With Files From Scripts
WriteToTextFile Method
OpenTextFile Method
aqFile.ReadWholeTextFile Method

Highlight search results