Created
March 15, 2018 16:16
-
-
Save bronumski/b9fe9bb2454873ae47d3523e90c04c8c to your computer and use it in GitHub Desktop.
Remove invalid chars from a file name using linq
This file contains hidden or 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
| public static string CleanFileName(string fileName) | |
| { | |
| return Path.GetInvalidFileNameChars().Aggregate(fileName, (current, c) => current.Replace(c.ToString(), string.Empty)); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment