CSharp examples for File IO:File Command
Removes any illegal file characters from a string vis Regex
using System.Text.RegularExpressions; using System.IO;/*from www.j a v a 2 s . c om*/ using System.Collections.Generic; using System; public class Main{ /// <summary> /// Removes any illegal file characters from a string /// </summary> public static string RemoveIllegalCharacters(string str) { //Remove characters... string c = str; Regex regex = new Regex(@"(\/|\*|\?|\||:|<|>)", RegexOptions.None); c = regex.Replace(c, @"."); //Trim it str = c.Trim(); //We have our new Infantry compatible string! return str; } }