.NET ez 2013-09-24
取得檔案的MD5值,可以用來判斷檔案是否已變更!
/// <summary>
/// 取的檔案指紋
/// </summary>
/// <param name="FileRoute">檔案路徑</param>
/// <returns>回傳MD5</returns>
public string GetFileMD5(string FileRoute)
{
if (File.Exists(FileRoute))
{
string str = string.Empty;
using (FileStream FS = new FileStream(FileRoute, FileMode.Open, FileAccess.Read))
{
byte[] bytes = (new MD5CryptoServiceProvider()).ComputeHash(FS);
str = BitConverter.ToString(bytes).Replace("-", string.Empty);
FS.Close();
}
return str;
}
else
return string.Empty;
}標籤: .NET
本文章網址:
https://www.ez2o.com/Blog/Post/csharp-File-MD5-Sample-Code
https://www.ez2o.com/Blog/Post/279
https://www.ez2o.com/Blog/Post/csharp-File-MD5-Sample-Code
https://www.ez2o.com/Blog/Post/279
