Make Sanitize File Name


/ Published in: C#
Save to your folder(s)



Copy this code and paste it in your HTML
  1. private static string MakeValidFileName( string name )
  2. {
  3. string invalidChars = Regex.Escape( new string( Path.GetInvalidFileNameChars() ) );
  4. string invalidReStr = string.Format( @"[{0}]+", invalidChars );
  5. return Regex.Replace( name, invalidReStr, "_" );
  6. }

URL: http://stackoverflow.com/questions/309485/c-sanitize-file-name

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.