public static bool FilesEqual(string filePathA, string filePathB)
{
filePathA = Path.GetFullPath(filePathA);
filePathB = Path.GetFullPath(filePathB);
if (filePathA == filePathB) return true;
if (!File.Exists(filePathA)) return false;
if (!File.Exists(filePathB)) return false;
using (FileStream streamA = File.OpenRead(filePathA))
using (FileStream streamB = File.OpenRead(filePathB))
{
if (streamA.Length != streamB.Length) return false;
while (streamA.Position < streamA.Length)
{
if (streamA.ReadByte() != streamB.ReadByte()) return false;
}
}
return true;
}