标签:tco creat string 字节 compute 文件 path write mod
using (HashAlgorithm hash = HashAlgorithm.Create())
{
using (FileStream file1 = new FileStream(FilePath1, FileMode.Open), file2 = new FileStream(FilePath2, FileMode.Open))
{
byte[] hashByte1 = hash.ComputeHash(file1);//哈希算法根据文本得到哈希码的字节数组
byte[] hashByte2 = hash.ComputeHash(file2);
string str1 = BitConverter.ToString(hashByte1);//将字节数组装换为字符串
string str2 = BitConverter.ToString(hashByte2);
if (str1 == str2)
{
//write
}
else
{
//write
}
}
}
标签:tco creat string 字节 compute 文件 path write mod
原文地址:https://www.cnblogs.com/liujiabao/p/10330871.html