From c552411b910ecf2ace1d63db9857621715f44e31 Mon Sep 17 00:00:00 2001 From: croire <1432593898@qq.com> Date: Sun, 30 Jan 2022 20:32:42 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=BB=E9=99=A4=E6=96=87=E4=BB=B6=E5=A4=B9?= =?UTF-8?q?=E5=90=8D/=E6=96=87=E4=BB=B6=E5=90=8D=E5=89=8D=E5=AF=BC?= =?UTF-8?q?=E5=92=8C=E5=B0=BE=E9=83=A8=E7=9A=84dot=E7=AC=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DownKyi.Core/Utils/Format.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/DownKyi.Core/Utils/Format.cs b/DownKyi.Core/Utils/Format.cs index c3a611c..910cafd 100644 --- a/DownKyi.Core/Utils/Format.cs +++ b/DownKyi.Core/Utils/Format.cs @@ -174,6 +174,7 @@ namespace DownKyi.Core.Utils public static string FormatFileName(string originName) { string destName = originName; + // Windows中不能作为文件名的字符 destName = destName.Replace("\\", " "); destName = destName.Replace("/", " "); @@ -197,7 +198,8 @@ namespace DownKyi.Core.Utils // 控制字符 destName = Regex.Replace(destName, @"\p{C}+", string.Empty); - return destName.Trim(); + // 移除前导和尾部的空白字符、dot符 + return destName.Trim().TrimStart('.').TrimEnd('.'); } }