Hmmm... not sure what you mean by comparing context. Perhaps you mean comparing content?
There's two ways:
1. Use
WinDiff.
2. Use
File.ReadAllBytes to get the bytes of each file, then loop through them to make sure they're the same.
public static bool FilesAreEqual(string filename1, string filename2)
{
byte[] firstFile = File.ReadAllBytes(filename1);
byte[] secondFile = File.ReadAllBytes(filename2);
// if the lengths don't match, the contents don't match.
if (firstFile.Length != secondFile.Length)
return false;
for (int i = 0; i < firstFile.Length; i++)
if (firstFile[i] != secondFile[i])
return false;
return true;
}
Coding Light - Illuminated Ideas and Algorithms in SoftwareCoding Light Wiki •
LinkedIn •
ForumsBrowser