纯粹为了记录,方便以后拷贝
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
namespace CompareBytesMd5
{
class Program
{
public static string CalculateMD5(string filePath)
{
try
{
var stream = File.OpenRead(filePath);
var res = CalculateMD5(stream);
stream.Close();
return res;
}
catch (Exception ex)
{
Console.WriteLine("xxxxxxxxxxxxxxxxx Error");
}
return "";
}
public static string CalculateMD5(Stream stream)
{
using (var md5Obj = System.Security.Cryptography.MD5.Create())
{
StreamReader sr = new StreamReader(stream, Encoding.UTF8);
string s = sr.ReadToEnd();
sr.Close();
sr.Dispose();