Fix import error due to invalid file name. (Amend)

This commit is contained in:
2022-11-07 12:19:31 +08:00
parent a401585f07
commit 0d7018c964

View File

@@ -1,5 +1,6 @@
using System;
using System.Text;
using System.Text.RegularExpressions;
namespace Cryville.Common {
/// <summary>
@@ -33,5 +34,13 @@ namespace Cryville.Common {
b.Append((timeSpan.TotalSeconds % 60).ToString("00." + new string('0', digits)));
return b.ToString();
}
/// <summary>
/// Escapes special characters in a file name.
/// </summary>
/// <param name="name">The file name excluding the extension.</param>
/// <returns>The escaped file name.</returns>
public static string EscapeFileName(string name) {
return Regex.Replace(name, @"[\/\\\<\>\:\x22\|\?\*\p{Cc}\.\s]", "_");
}
}
}