Walter.IO
FileIsEqualToIgnoringPadding Method
Walter.IO Assembly > Walter.IO Namespace > FileInfoExtensions Class : FileIsEqualToIgnoringPadding Method
The source file to compare.
The file to compare against the source file.
Compares the binary content of two files to determine if they are identical, excluding any differences in padding (trailing zeros).
Syntax
public static bool FileIsEqualToIgnoringPadding( 
   FileInfo source,
   FileInfo compareTo
)

Parameters

source
The source file to compare.
compareTo
The file to compare against the source file.

Return Value

true if the binary content of both files is identical when ignoring padding; otherwise, false. This method is particularly useful for detecting if a file has been altered in a manner that might not affect its operational integrity but could be indicative of tampering or an attempt to evade detection by changing its size.
Exceptions
ExceptionDescription
Thrown if either source or compareTo is null.
Thrown if the source file does not exist.
Other exceptions may be thrown if reading the file's binary content fails.
Remarks
This method reads the entire binary content of each file into memory, so it may not be suitable for very large files or environments with limited memory availability. It is optimized for comparing files where padding differences are not considered to alter the file's functionality or identity, such as executables or system files that might be targeted for tampering.
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

FileInfoExtensions Class
FileInfoExtensions Members