mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[DatItem, Style] Try to remove path-unsafe characters from file names
This commit is contained in:
@@ -429,6 +429,18 @@ namespace SabreTools.Helper
|
||||
return (s.Any(c => c > 255));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove all chars that are considered path unsafe
|
||||
/// </summary>
|
||||
/// <param name="s">Input string to clean</param>
|
||||
/// <returns>Cleaned string</returns>
|
||||
public static string RemovePathUnsafeCharacters(string s)
|
||||
{
|
||||
List<char> invalidPath = Path.GetInvalidPathChars().ToList();
|
||||
List<char> invalidName = Path.GetInvalidFileNameChars().ToList();
|
||||
return new string(s.Where(c => !invalidPath.Contains(c) && !invalidName.Contains(c)).ToArray());
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Externally sourced methods
|
||||
|
||||
Reference in New Issue
Block a user