fileMismatch

Compares two files byte by byte. Returns -1 if they are identical, otherwise the 0-based byte position of the first difference.

fileMismatch(filepath1, filepath2) → returns numeric

This function requires Adobe ColdFusion 2025 and up.  Not supported on Lucee, etc.

Argument Reference

filepath1 string
Required

Path to the first file.

filepath2 string
Required

Path to the second file.

Examples
Sample code invoking the fileMismatch function

The files match up to line, so the first difference is at byte 10.

a = getTempFile(getTempDirectory(), "a");
b = getTempFile(getTempDirectory(), "b");
fileWrite(a, "line1#chr(10)#line2");
fileWrite(b, "line1#chr(10)#lineX");
writeOutput(fileMismatch(a, b));

Expected Result: 10

Signup for cfbreak to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.

Fork me on GitHub