Duality.PathHelper.FilesEqual C# (CSharp) Method

FilesEqual() public static method

Determines whether the contents of two files are completely equal.
public static FilesEqual ( string filePathA, string filePathB ) : bool
filePathA string
filePathB string
return bool
        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;
        }