• MD5文件去重


         //计算文件的MD5码

            private string getMD5Hash(string pathName)

            {

                string strResult = "";

                string strHashData = "";

     

                byte[] arrbytHashValue;

                System.IO.FileStream oFileStream = null;

     

                System.Security.Cryptography.MD5CryptoServiceProvideroMD5Hasher =

                           newSystem.Security.Cryptography.MD5CryptoServiceProvider();

     

                try

                {

                    oFileStream = new System.IO.FileStream(pathName, System.IO.FileMode.Open,

                          System.IO.FileAccess.Read, System.IO.FileShare.ReadWrite));

                    arrbytHashValue = oMD5Hasher.ComputeHash(oFileStream);//计算指定Stream 对象的哈希值

                    oFileStream.Close();

                    //由以连字符分隔的十六进制对构成的String,其中每一对表示value 中对应的元素;例如“F-2C-4A”

                    strHashData = System.BitConverter.ToString(arrbytHashValue);

                    //替换-

                    strHashData = strHashData.Replace("-", "");

                    strResult = strHashData;

                }

                catch (System.Exception ex)

                {

                    MessageBox.Show(ex.Message);

                }

     

                return strResult;

            }

  • 相关阅读:
    vuejs cli3 env配置文件实践指南
    Nginx的rewrite(地址重定向)剖析
    什么是TCP粘包?怎么解决这个问题
    windows bat批处理语法简析
    BAT文件语法和技巧(bat文件的编写及使用)
    Asyncio之EventLoop笔记
    python struct的使用例子
    redis慢查询笔记
    redis基础操作概念等笔记
    Python实现Dijkstra算法
  • 原文地址:https://www.cnblogs.com/Justsoso-WYH/p/8745000.html
Copyright © 2020-2023  润新知