From 58eee793bd48a558c275cac04ec576b7e6666b26 Mon Sep 17 00:00:00 2001 From: 13693261870 <252740454@qq.com> Date: 星期四, 24 八月 2023 16:09:02 +0800 Subject: [PATCH] 修改获取文件大小的方法 --- DataLoader/CS/Tools.cs | 20 ++++++++++++++------ 1 files changed, 14 insertions(+), 6 deletions(-) diff --git a/DataLoader/CS/Tools.cs b/DataLoader/CS/Tools.cs index 365e538..5017513 100644 --- a/DataLoader/CS/Tools.cs +++ b/DataLoader/CS/Tools.cs @@ -9,8 +9,6 @@ using System.Net.Sockets; using System.Net; using System.Reflection; -using System.Text; -using System.Threading.Tasks; namespace DataLoader.CS { @@ -47,7 +45,7 @@ /// </summary> public static string FormatBytes(long bytes) { - string[] Suffix = { "Byte", "KB", "MB", "GB", "TB" }; + string[] Suffix = { "B", "KB", "MB", "GB", "TB" }; // Byte int i = 0; double dblSByte = bytes; @@ -55,7 +53,7 @@ for (i = 0; (bytes / 1024) > 0; i++, bytes /= 1024) dblSByte = bytes / 1024.0; - return String.Format("{0:0.##}{1}", dblSByte, Suffix[i]); + return string.Format("{0:0.##} {1}", dblSByte, Suffix[i]); } /// <summary> @@ -68,9 +66,19 @@ return 0.001; } - String str = string.Format("{0:F3}", size / 1024.0 / 1024.0); + string str = string.Format("{0:F3}", size / 1024.0 / 1024.0); - return Double.Parse(str); + return double.Parse(str); + } + + /// <summary> + /// 淇濈暀3浣嶅皬鏁� + /// </summary> + public static double Round3(double val) + { + string str = string.Format("{0:F3}", val); + + return double.Parse(str); } /// <summary> -- Gitblit v1.9.3