/// <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));
}
}
}
比较两文件是否一致
精选 转载下一篇:我的友情链接
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
MySQL 主从 AUTO_INCREMENT 不一致问题分析
本文介绍了MySQL5.7 中常见的replace into 操作造成的主从auto_increment不一致现象,一旦触发了主从切换,业务的正常插入操作会触发主键冲突的报错提示。
MySQL典型案例 replace into auto_increment -
判断两文件是否一致
整理中……
职场 休闲 判断一致