aqFile.Compare Method

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

Description

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

Declaration

aqFile.Compare(PathToFile1, PathToFile2)

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 (! aqFile.Compare("C:\\Work\\OrdersList_old.txt", "C:\\Work\\OrdersList.txt") )
   Log.Warning("List of orders was changed");
}

Python

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

VBScript

Sub CompareFilesExample

  If Not aqFile.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 aqFile.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 (! aqFile["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