Created
November 13, 2011 01:55
-
-
Save Seich/1361472 to your computer and use it in GitHub Desktop.
Cleans filenames, source: http://stackoverflow.com/questions/309485/c-sharp-sanitize-file-name/847251#847251
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
public static string MakeValidFileName( string name ) | |
{ | |
string invalidChars = Regex.Escape( new string( Path.GetInvalidFileNameChars() ) ); | |
string invalidReStr = string.Format( @"[{0}]+", invalidChars ); | |
return Regex.Replace( name, invalidReStr, "_" ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment