Created
March 28, 2014 10:03
-
-
Save sondreb/9829299 to your computer and use it in GitHub Desktop.
One-liner that sanitizes the file name. Remember: There is a different method to get invalid path chars.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Remove any invalid file name characters that might have been added to the name. | |
var newName = string.Join("_", fileName.Split(Path.GetInvalidFileNameChars(), StringSplitOptions.RemoveEmptyEntries)).TrimEnd('.'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment