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

CRC32 File Function
File Operations Class

Public Function CRC32File( _
      ByVal vFileName As Variant _
    , Optional ByVal vStartCRC As Variant _
    ) As Variant

"File 32-bit Cyclical Redundancy Check (CRC)"
Finds the PKZIP compatible CRC of any size file.
Return the 32-bit CRC value for the characters within a file.
Unlike a checksum, the position of the characters within file affects the result.
Matching CRC values are a much more reliable indicator of the accuracy of data than matching checksum values.

Example:
    Assuming
       CRC32String("ABCD") = -619241307
       StringToFile("ABCD", "C:\Test.Out") = True
    for example
       CRC32File("C:\Test.Out") = -619241307
See also:
    CRC32String Function
    Checksum32File Function
    CRC32FileSample Subroutine
vFileName: Name of the file for which the CRC will be calculated. Function returns Null if vFileName is Null or cannot be fixed-up to a string. Function returns Null if there is any type of error, such as when the file does not exist.

vStartCRC: The starting CRC value. vStartCRC defaults to &HFFFFFFFF (2^32 - 1 unsigned long; -1 signed long) if it is missing or Null or cannot be fixed up to a number. The default CRC value of &HFFFFFFFF should be used in most cases where the CRC of a single string is to be calculated. This argument is provided for those cases where the CRC of multiple FILES are to be calculated one file at a time.

Note: This function returns a Long integer value which really represents an unsigned long value. The most-significant-bit of the return value really represents the most significant bit of an unsigned value; it does not represent the sign bit of a signed value. For example, negative return values represent the values within the range from 2^31 through 2^32-1.
v1.1 BugBix: Corrected a bug in this function that might have caused it to not work in v1.0. For some reason, VB 4.0 was truncating all of the Long hex Constants that were required by this function.
Tip: We suggest using Long decimal Constants (like -1&) instead of Long hex Constants (like &HFFFFFFFF) wherever possible.

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