ReadWholeTextFile Method

Applies to TestComplete 15.70, last modified on December 17, 2024

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

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 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
ReadWholeTextFile Method

Highlight search results