SocketTools .NET Edition

FileEncoder.CompareFile Method (String, String)

Compares the contents of two files.

[Visual Basic]
Overloads Public Function CompareFile( _
   ByVal fileName1 As String, _
   ByVal fileName2 As String _
) As Boolean
[C#]
public bool CompareFile(
   string fileName1,
   string fileName2
);

Parameters

fileName1
A string which specifies the name of the first file to compare.
fileName2
A string which specifies the name of the second file to compare.

Return Value

A boolean value which specifies if the contents of two files are identical.

Remarks

It is permitted to use environment variables in a file name by surrounding the variable name with the percent symbol. If the file name contains any leading or trailing space characters after the variable expansion, they will be removed. The file must exist and the current process must have permission to read the contents of the file.

This method will normalize the file names and perform checks to make sure the names do not contain illegal characters. If the name includes quotes, wildcard characters or other invalid symbols the method will fail and with the last error code set to InvalidFileName. It is permitted to use forward slashes in path names and these will be converted to the standard backslash character used with Windows paths. This method cannot be used to compare the contents of NTFS alternate data streams.

See Also