using System.Security.Cryptography;
using System.IO;
public static string GetFileHash(string filePath)
{
using(MD5CryptoServiceProvider md5 =new MD5CryptoServiceProvider())
using (FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read))
{
return BitConverter.ToString(md5.ComputeHash(fs)).Replace("-","");
}
}
private void button1_Click(object sender, EventArgs e)
{
string fileHash = GetFileHash(@"D:\temp.txt");
MessageBox.Show(fileHash);
}