From 550e65b657f0eccd513ba91339fb8f0ea3f9fa02 Mon Sep 17 00:00:00 2001 From: 13693261870 <252740454@qq.com> Date: 星期日, 01 一月 2023 16:18:05 +0800 Subject: [PATCH] 1.1.7 --- DataLoader/Model/Tool.cs | 67 +++++++++++++++++++++++++++++++++ 1 files changed, 67 insertions(+), 0 deletions(-) diff --git a/DataLoader/Model/Tool.cs b/DataLoader/Model/Tool.cs index e9c6a32..4f3b08c 100644 --- a/DataLoader/Model/Tool.cs +++ b/DataLoader/Model/Tool.cs @@ -3,8 +3,10 @@ using System.Collections.Generic; using System.Configuration; using System.Data.Common; +using System.IO; using System.Linq; using System.Reflection; +using System.Runtime.InteropServices.ComTypes; using System.Text; using System.Threading.Tasks; using System.Windows; @@ -22,6 +24,8 @@ public static string Uname = ""; public static string Token = ""; + + public static char[] HEX_DIGITS = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; public static string FormatBytes(long bytes) { @@ -74,5 +78,68 @@ return list; } + + /*//2a0befb05146cd30213ee4b95038aca0 + public static String getFileMd5(String filePath) + { + FileStream fis = null; + try + { + MessageDigest md = MessageDigest.getInstance("MD5"); + + fis = new FileStream(new File(filePath)); + FileChannel fChannel = fis.getChannel(); + Byte[] buffer =new Byte[1024 * 1024]; + + while (fChannel.read(buffer) != -1) + { + buffer.flip(); + md.update(buffer); + buffer.compact(); + } + byte[] b = md.digest(); + + return byteToHexString(b); + } + catch (Exception ex) + { + return null; + } + finally + { + try + { + if (null != fis) + { + fis.Dispose(); + } + } + catch (Exception ex) + { + // + } + } + } + + public static String byteToHexString(byte[] tmp) + { + // 姣忎釜瀛楄妭鐢� 16 杩涘埗琛ㄧず鐨勮瘽锛屼娇鐢ㄤ袱涓瓧绗︼紝 + char[] str = new char[16 * 2]; + + int k = 0; + for (int i = 0; i < 16; i++) + { + // 杞崲鎴� 16 杩涘埗瀛楃鐨勮浆鎹� + byte byte0 = tmp[i]; + + // 鍙栧瓧鑺備腑楂� 4 浣嶇殑鏁板瓧杞崲 + str[k++] = HEX_DIGITS[byte0 >> 4 & 0xf]; + + // >>> 涓洪�昏緫鍙崇Щ锛屽皢绗﹀彿浣嶄竴璧峰彸绉伙紝 鍙栧瓧鑺備腑浣� 4 浣嶇殑鏁板瓧杞崲 + str[k++] = HEX_DIGITS[byte0 & 0xf]; + } + + return new String(str); + }*/ } } -- Gitblit v1.9.3