1. public static string GetFileMd5Hash(string strFileFullPath)
    2. {
    3. // Create a new instance of the MD5CryptoServiceProvider object.
    4. System.IO.FileStream fst = null;
    5. try
    6. {
    7. fst = new System.IO.FileStream(strFileFullPath, System.IO.FileMode.Open);
    8. System.Security.Cryptography.MD5 md5 = new System.Security.Cryptography.MD5CryptoServiceProvider();
    9. // Convert the input string to a byte array and compute the hash.
    10. byte[] data =md5 .ComputeHash(fst);
    11. // Create a new Stringbuilder to collect the bytes
    12. // and create a string.
    13. StringBuilder sBuilder = new StringBuilder();
    14. // Loop through each byte of the hashed data
    15. // and format each one as a hexadecimal string.
    16. for (int i = 0; i < data.Length; i++)
    17. {
    18. sBuilder.Append(data[i].ToString("x2"));
    19. }
    20. fst.Close();
    21. // Return the hexadecimal string.
    22. return sBuilder.ToString().ToLower();
    23. }
    24. catch (System.Exception ex)
    25. {
    26. if (fst != null)
    27. fst.Close();
    28. return "";
    29. }
    30. finally
    31. {
    32. }
    33. }