You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.2 KiB

  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. namespace Apewer.Run
  8. {
  9. class HashComputer
  10. {
  11. public HashComputer()
  12. {
  13. var path = @"Y:\telecast\新白娘子传奇";
  14. var subs = StorageUtility.GetSubFiles(path, true);
  15. subs.Sort();
  16. var array = Json.NewArray();
  17. foreach (var sub in subs)
  18. {
  19. var md5 = "";
  20. using (var file = StorageUtility.OpenFile(sub))
  21. {
  22. var info = new FileInfo(sub);
  23. var length = info.Length;
  24. md5 = BinaryUtility.MD5(file, (p) =>
  25. {
  26. Console.WriteLine($"{sub} total={length} progress={p}");
  27. }).ToX2();
  28. }
  29. Console.WriteLine($"{sub} md5={md5}");
  30. var item = Json.NewObject();
  31. item["path"] = sub;
  32. item["md5"] = md5;
  33. array.AddItem(item);
  34. }
  35. StorageUtility.WriteFile(path + ".json", array.ToString(true).ToBinary());
  36. }
  37. }
  38. }