public static string ComputeMD5Hash(string fileName)
{
string md5 = null;
try
{
using (FileStream stream = File.OpenRead(fileName))
{
using (var bufferedStream = new BufferedStream(stream, 1024 * 32))
{
using (var sha = new MD5Cng())
{
byte[] checksum = sha.ComputeHash(bufferedStream);
md5 = BitConverter.ToString(checksum).Replace("-", string.Empty);
}
}
}
}
catch (IOException) { }
catch (UnauthorizedAccessException) { }
return md5;
}