/// <summary>
/// 判断两个文件内容是否一致 /// </summary> public static bool IsFilesEqual(string fileName1, string fileName2) { using (HashAlgorithm hashAlg = HashAlgorithm.Create()) { using (FileStream fs1 = new FileStream(fileName1, FileMode.Open), fs2 = new FileStream(fileName2, FileMode.Open)) { byte[] hashBytes1 = hashAlg.ComputeHash(fs1); byte[] hashBytes2 = hashAlg.ComputeHash(fs2); // 比较哈希码 return (BitConverter.ToString(hashBytes1) == BitConverter.ToString(hashBytes2)); } } }