Thursday, June 14, 2012

Function to clean string for folder creation


public static string stripIllegal(string str)
       {
           string regex = String.Format("[{0}]", Regex.Escape(new string(Path.GetInvalidFileNameChars())));
      return Regex.Replace(str,regex,"-");
       }

in this case I exchange invalid char with -

No comments:

Post a Comment