不知道为什么对Excel 2010 xlsx后缀的文件没有效果,求解!

对其他文件有效,如.txt,.csv

 1 using System;
 2 using System.Security.Cryptography;
 3 using System.IO;
 4 
 5 namespace CheckFile
 6 {
 7     class Program
 8     {
 9         static void Main(string[] args)
10         {
11             string filePath1 = @"D:/1.txt";
12             string filePath2 = @"D:/2.txt";
13             bool result = CheckFile(filePath1, filePath2);
14             Console.WriteLine(result.ToString());
15             Console.ReadKey();
16 
17         }
18         /// <summary>
19         /// Check File
20         /// </summary>
21         /// <param name="filePath1"></param>
22         /// <param name="filePath2"></param>
23         /// <returns></returns>
24         public static bool CheckFile(string filePath1, string filePath2)
25         {
26             using (HashAlgorithm hash = HashAlgorithm.Create())
27             {
28                 using (FileStream file1 = new FileStream(filePath1, FileMode.Open, FileAccess.Read)
29                     , file2 = new FileStream(filePath2, FileMode.Open, FileAccess.Read))
30                 {
31                     byte[] hashByte1 = hash.ComputeHash(file1);
32                     byte[] hashByte2 = hash.ComputeHash(file2);
33                     string str1 = BitConverter.ToString(hashByte1);
34                     string str2 = BitConverter.ToString(hashByte2);
35                     return (str1 == str2);
36                 }
37             }
38         }
39     }
40 }

 

相关文章:

  • 2021-11-18
  • 2022-01-11
  • 2022-12-23
  • 2021-05-29
  • 2022-12-23
  • 2022-12-23
  • 2022-03-08
  • 2022-12-23
猜你喜欢
  • 2021-12-16
  • 2021-09-22
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-06
  • 2021-11-28
相关资源
相似解决方案