• 用MD5比较两文件是否相等


    public static bool CompareFile(string strSource, string strTarget)
    {
    using (HashAlgorithm hash = HashAlgorithm.Create())
    {
    using (FileStream file1 = new FileStream(strSource, FileMode.Open), file2 = new FileStream(strTarget, FileMode.Open))
    {
    using (MD5 md5_1 = new MD5CryptoServiceProvider(), md5_2 = new MD5CryptoServiceProvider())
    {
    byte[] hashByte1 = md5_1.ComputeHash(file1);
    byte[] haahByte2 = md5_2.ComputeHash(file2);
    string str1 = BitConverter.ToString(hashByte1);
    string str2 = BitConverter.ToString(haahByte2);
    return (str1 == str2);
    }
    }
    }
    }

  • 相关阅读:
    exchangeNetwork
    VRP OS Management
    filleSystemBasises
    Study_way
    1.MySQL 安装
    7.进程池与线程池
    6.线程
    5.进程 -锁
    4.进程-1
    3.多线程TCP协议与加密方式
  • 原文地址:https://www.cnblogs.com/zjq1989/p/5527776.html
Copyright © 2020-2023  润新知