public static string SterilizeTagClassName(string name) { // http://stackoverflow.com/questions/309485/c-sharp-sanitize-file-name string regex = string.Format(@"(\.+$)|([{0}])", InvalidFileNameChars); return Regex.Replace(name, regex, "_"); }