INF: How to Detect and Compare File Differences

ID: Q119110


The information in this article applies to:


SUMMARY

It is common to encounter situations where you need to verify whether two disk files are identical. For example, you may observe unusual program behavior and suspect the file is damaged. Or two files may have the same byte count but different dates, and you wish to be certain they are identical. You may also be sending files to someone and prior to sending you wish to verify them against a master copy. In some cases, these files may be readable ASCII, and in other cases, binary. Sometimes you may need to compare a local file to a questionable file at a remote site.

The only way to positively verify the files are identical is by using the techniques listed here or similar ones. The file-byte count and creation date are not reliable indications.

If a file is suspect, often the solution taken is to recopy from a known good file. This may solve the problem but prevents ever knowing for certain whether the original file was damaged. It can be important to determine this, as the file damage can indicate an underlying network or system problem. This article discusses how to compare files using utilities that are either commonly available or part of Windows NT and the Windows NT Resource Kit.


MORE INFORMATION

For comparing a local file to a remote file, it is often best to use the pkzip utility. Pkzip the file at both the local and remote sites. Then use pkzip -v to examine the CRC-32 value for the ZIP files. If the CRC-32 values are identical for the remote and local sites, then the files are absolutely identical. Since ZIPing a large file can take some time, it is often best to use the pkzip -e0 (no compression) option, which is fastest.

If a file is ZIPed with PKZIP before sending to a remote site, the embedded CRC-32 will ensure notification if the file is damaged in transit. This will be seen as an error during the unzip process. If there is no error, the file was conveyed without damage.

For comparing two files or groups of files at a local site, there are several options: The FC.EXE and COMP.EXE comparison utilities both ship with Windows NT. WINDIFF.EXE ships with the Windows NT Resource Kit. FC.EXE is good for comparing two ASCII or binary files and has several different parameters. For example, use FC /b to compare two binary files.

COMP.EXE can be used to compare groups of files in two different directories. For example,


   COMP c:\winnt\system32\*.dll \\remotesys\c$\winnt\system32\*.dll 

compares all DLLs in the indicated directories on two different machines.

If you need to compare entire subdirectory trees, the WINDIFF utility from the Windows NT Resource Kit can be used. WINDIFF is a graphical Win32 utility. It is also excellent for doing detailed comparison between two ASCII files, such as source code. It graphically illustrates with colors the difference between the two ASCII files.

Additional query words: pkzip compare remote Windows NT


Keywords          : kbother SSrvWinNT 
Version           : 4.2
Platform          : WINDOWS 
Issue type        : 

Last Reviewed: March 20, 1999