首页 > 学院 > 开发设计 > 正文

得到文件的MD5值

2019-11-17 02:00:46
字体:
来源:转载
供稿:网友

得到文件的md5

/// <summary>        /// 得到文件的MD5值        /// </summary>        /// <param name="Path">文件路径</param>        /// <returns></returns>        public static string GetFileMD5Code(string Path)        {            try            {                if (System.IO.File.Exists(Path))                {                    System.IO.FileStream Get_File = new System.IO.FileStream(Path, System.IO.FileMode.Open, System.IO.Fileaccess.Read, System.IO.FileShare.Read);                    System.Security.Cryptography.MD5CryptoServicePRovider Get_MD5 = new System.Security.Cryptography.MD5CryptoServiceProvider();                    byte[] Hash_byte = Get_MD5.ComputeHash(Get_File);                    string Result = System.BitConverter.ToString(Hash_byte);                    Result = Result.Replace("-", "");                    return Result;                }                else                {                    return "文件路径错误!";                }                         }            catch (Exception e)            {               return e.Message;            }        }
View Code


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表