public static bool CompareFile(string strSource, string strTarget)
{
using (HashAlgorithm hash = HashAlgorithm.Create())
{
using (FileStream file1 = new FileStream(strSource, FileMode.Open), file2 = new FileStream(strTarget, FileMode.Open))
{
using (MD5 md5_1 = new MD5CryptoServiceProvider(), md5_2 = new MD5CryptoServiceProvider())
{
byte[] hashByte1 = md5_1.ComputeHash(file1);
byte[] haahByte2 = md5_2.ComputeHash(file2);
string str1 = BitConverter.ToString(hashByte1);
string str2 = BitConverter.ToString(haahByte2);
return (str1 == str2);
}
}
}
}