From c95840c681a5fa39a6d2358143ccd7dcf68a5f11 Mon Sep 17 00:00:00 2001 From: croire <1432593898@qq.com> Date: Fri, 6 Jan 2023 15:27:25 +0800 Subject: [PATCH] Fix FormatFileName --- DownKyi.Core/Utils/Format.cs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/DownKyi.Core/Utils/Format.cs b/DownKyi.Core/Utils/Format.cs index 6e0faf1..fcde0f6 100644 --- a/DownKyi.Core/Utils/Format.cs +++ b/DownKyi.Core/Utils/Format.cs @@ -199,7 +199,22 @@ namespace DownKyi.Core.Utils destName = Regex.Replace(destName, @"\p{C}+", string.Empty); // 移除前导和尾部的空白字符、dot符 - return destName.Trim('.').Trim(); + int i, j; + for (i = 0; i < destName.Length; i++) + { + if (destName[i] != ' ' && destName[i] != '.') + { + break; + } + } + for (j = destName.Length - 1; j >= 0; j--) + { + if (destName[j] != ' ' && destName[j] != '.') + { + break; + } + } + return destName.Substring(i, j - i + 1); } }