aqFile.Compare Method

Applies to TestComplete 14.71, last modified on April 22, 2021

Description

Use the aqFile.Compare method to compare two files byte-by-byte.

Declaration

aqFile.Compare(PathToFile1PathToFile2)

PathToFile1 [in]    Required    String    
PathToFile2 [in]    Required    String    
Result Boolean

Applies To

The method is applied to the following object:

Parameters

The method has the following parameters:

PathToFile1

Specifies the fully-qualified path to the file to be compared.

PathToFile2

Specifies the fully-qualified path to the file to be compared.

Result Value

True if the specified files are identical, and False otherwise.

Example

The code below demonstrates how to compare two versions of a file to check whether the primary one was changed.

JavaScript, JScript

function CompareFilesExample()
{
  if (! Files.Compare("C:\\Work\\OrdersList_old.txt", "C:\\Work\\OrdersList.txt") )
   Log.Warning("List of orders was changed");
}

Python

def CompareFilesExample():
  if not Files.Compare("C:\\Work\\OrdersList_old.txt", "C:\\Work\\OrdersList.txt"):
    Log.Warning("List of orders was changed")

VBScript

Sub CompareFilesExample

  If Not Files.Compare("C:\Work\OrdersList_old.txt", "C:\Work\OrdersList.txt") Then
   Log.Warning("List of orders was changed")
  End If

End Sub

DelphiScript

function CompareFilesExample;
begin
  if not Files.Compare('C:\Work\OrdersList_old.txt', 'C:\Work\OrdersList.txt') then
   Log.Warning('List of orders was changed');
end;

C++Script, C#Script

function CompareFilesExample()
{
  if (! Files["Compare"]("C:\\Work\\OrdersList_old.txt", "C:\\Work\\OrdersList.txt") )
   Log["Warning"]("List of orders was changed");
}

See Also

Working With Files From Scripts
Create Method
Rename Method
Copy Method

Highlight search results