获取文件Md5值

        private static string GetFileMD5(string filePath)
{
string _md5Value = string.Empty;
try
{
if (System.IO.File.Exists(filePath))
{
FileStream file = new FileStream(filePath, FileMode.Open);
System.Security.Cryptography.MD5 md5 = new System.Security.Cryptography.MD5CryptoServiceProvider();
byte[] retVal = md5.ComputeHash(file);
file.Close();
file.Dispose();
_md5Value= BitConverter.ToString(retVal).Replace("-", "");
}
return _md5Value;
}
catch (Exception ex)
{
//throw new Exception(string.Format("GetFileMD5_Error_{0}_{1}", DateTime.Now, ex.Message));
return _md5Value;
}
}
上一篇:在vmware中实现Ubuntu与win7(主机)之间同步实现共享文件


下一篇:T-SQL查询:语句执行顺序