您好,欢迎访问一九零五行业门户网

怎么判断两个文件是否是同一个文件 (代码)

本篇文章给大家带来的内容是关于怎么判断两个文件是否是同一个文件 (代码),有一定的参考价值,有需要的朋友可以参考一下,希望对你有所帮助。
通过system.security.cryptography.hashalgorithm 哈希算法获取文件的哈希值比较判断
public static bool comparefile(string filepath1, string filepath2)        {            //计算第一个文件的哈希值            hashalgorithm hash = hashalgorithm.create();            var stream_1 = new system.io.filestream(filepath1, system.io.filemode.open);            byte[] hashbyte_1 = hash.computehash(stream_1);            stream_1.close();            //计算第二个文件的哈希值            var stream_2 = new system.io.filestream(filepath2, system.io.filemode.open);            byte[] hashbyte_2 = hash.computehash(stream_2);            stream_2.close();            return bitconverter.tostring(hashbyte_1) == bitconverter.tostring(hashbyte_2);        }
以上就是对怎么判断两个文件是否是同一个文件 (代码)的全部介绍,如果您想了解更多有关c++视频教程,请关注。
以上就是怎么判断两个文件是否是同一个文件 (代码)的详细内容。
其它类似信息

推荐信息