using System;
using System.IO;
using System.Security.Cryptography;
using System.Text;


    public class MD5Code
    {
        /// <summary>
        /// Get 文件的MD5校验码
        /// </summary>
        /// <param name="fileName">文件名称</param>
        /// <returns></returns>
        public static string GetMD5HashFromFile(string fileName)
        {
           
            
                var file = new FileStream(fileName, System.IO.FileMode.Open);
                var md5 = new MD5CryptoServiceProvider();
                var bytes= md5.ComputeHash(file);
                file.Close();
                var sb = new StringBuilder();
                for (int i = 0; i < bytes.Length; i++)
                {
                    sb.Append(bytes[i].ToString("x2"));
                }
                return sb.ToString();
        
          }
    }