<-- Previous || Up || Next -->

Compare Files Function
File Operations Class

Public Function CompareFiles( _
      ByVal vFileOne As Variant _
    , ByVal vFileTwo As Variant _
    ) As Variant

Compare two files to determine if they have the same contents.
Return 0 if they are the same,
Return 1 if they are different.
Return -1 in case of most errors.

Return value:
     1: File sizes differ OR file contents differ.
     0: File sizes AND file contents are the same.
    -1: There were errors accessing one or both files.
Examples:
    ' Assumes C:\COMMAND.COM and C:\AUTOEXEC.BAT both exist
    ' and that they have different contents.
    CompareFiles("C:\COMMAND.COM", "C:\COMMAND.COM") = 0
    CompareFiles("C:\COMMAND.COM", "C:\AUTOEXEC.BAT") = 1
    ' #3 assumes C:\TEMP is a directory or an unused file name.
    CompareFiles("C:\COMMAND.COM", "C:\TEMP") = -1 ' #3
See also:
    Comparisons Class
    StrComp Function (Visual Basic)
vFileOne: Name of the first of two files whose contents will be compared. Function returns Null if vFileOne is Null or cannot be fixed-up to a string.

vFileTwo: Name of the seconds of two files whose contents will be compared. Function returns Null if vFileTwo is Null or cannot be fixed-up to a string.

Note: The file dates and attributes may differ, but as long as the two files have the same size and contents then they will be considered the same by this function.

Copyright 1996-1999 Entisoft
Entisoft Tools is a trademark of Entisoft.