创建MD5值: 作用: 可以根据文件的MD5码查看文件是否被更改 具体内容: public string CreateFileMD5(string FileName) { string MD5str = string.Empty; MD5 oMD = MD5.Create(); try { FileStream oStream = File.Open(FileName, FileMode.Open);//创建并打开文件流 Byte[] oBTem = oMD.ComputeHash(oStream);//计算MD5值 oStream.Close();//关闭文件流 MD5str = BitConverter.ToString(oBTem); MD5str = MD5str.Replace("-", ""); } catch (System.Exception ex) { Console.Write("失败了" + "!/r/n"); return ""; } Console.Write("【" + DateTime.Now.ToString() + "】" + ": 文件路径:" + Path.GetFileName(FileName) + "!/r/n"); Console.Write("【" + DateTime.Now.ToString() + "】" + ": MD5码:" + MD5str + "!/r/n/r/n"); return MD5str; }