FileCompare

Compares two files and reports on the result.

Syntax:

FileCompare(filename1, filename2)

Parameters:

(s) filename1 name of first file to compare

(s) filename2 name of second file to compare

Returns:

(i) compare result. Possible values are: 

 0 Files contents are identical. 

 1 Files are same size but different - first file is newer.
-1 Files are same size but different - second file is newer.

 2 Files are different - first file is newer.
-2 Files are different - second file is newer.
3 Second file missing - only first file exists. 

-3 First file missing - only second file exists.
4 Neither file exists. 

 

Use this function to compare two files to determine if they are identical or not. If the return value is zero, the file contents are identical. If the return value is not zero, the actual value provides additional information on why they didn’t compare.

An actual byte by byte compare is performed only if the file sizes are identical, otherwise it is obvious that the files must be different.

IMPORTANT: If the byte by byte compare is identical, then FileCompare will return 0 (identical) regardless of the file dates.

This function supports extended-length path names.

Example:


;Assuming a copy of win.ini has been previously made to win.sav
a=FileCompare("WIN.INI", "WIN.SAV")
If a==0
   Message("Info", "WIN.INI not modified")
Else
   Message("Alert!", "WIN.INI has been modified")
EndIf
See Also:

ExeTypeInfo, FileCopy, FileMove, FileDelete