Trims trailing spaces and dots when escaping file name instead of replacing them.
This commit is contained in:
@@ -40,7 +40,9 @@ namespace Cryville.Common {
|
|||||||
/// <param name="name">The file name excluding the extension.</param>
|
/// <param name="name">The file name excluding the extension.</param>
|
||||||
/// <returns>The escaped file name.</returns>
|
/// <returns>The escaped file name.</returns>
|
||||||
public static string EscapeFileName(string name) {
|
public static string EscapeFileName(string name) {
|
||||||
return Regex.Replace(name, @"[\/\\\<\>\:\x22\|\?\*\p{Cc}\.\s]", "_");
|
var result = Regex.Replace(name, @"[\/\\\<\>\:\x22\|\?\*\p{Cc}]", "_").TrimEnd(' ', '.');
|
||||||
|
if (result.Length == 0) return "_";
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user