[RomTools] Try to make sort more safe

This commit is contained in:
Matt Nadareski
2016-09-11 17:40:46 -07:00
parent 9d3019dfaa
commit a595a54f7b
2 changed files with 32 additions and 13 deletions

View File

@@ -514,6 +514,17 @@ namespace SabreTools.Helper
return 0;
}
/// <summary>
/// http://stackoverflow.com/questions/146134/how-to-remove-illegal-characters-from-path-and-filenames
/// </summary>
public static string StripInvalidPathChars(string s)
{
string regexSearch = new string(Path.GetInvalidFileNameChars()) + new string(Path.GetInvalidPathChars());
Regex r = new Regex(string.Format("[{0}]", Regex.Escape(regexSearch)));
s = r.Replace(s, "");
return s;
}
#endregion
}
}