Fix FormatFileName

修复当文件名以连续的点、空格、点结尾 (例如"abc . . ")时,无法完全去除开头/结尾的点和空格
需要额外处理当文件名都是非法字符的情况
pull/613/head
MoguCloud 2 years ago committed by GitHub
parent eef382c867
commit d8b747a48d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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);
}
}

Loading…
Cancel
Save