using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Text.RegularExpressions; using System.IO; namespace TradeIdeas.TIProGUI { public class FileNameMethod { //This class contains a method to remove illegal characters in file names. Illegal characters are replcaed //with the underscore "_" character. public static string QuoteFileName(string fileName) { string new_FileName = ""; if (fileName != null) { string regexSearch = new string(Path.GetInvalidFileNameChars()) + new string(Path.GetInvalidPathChars()); const string QuoteChar = "_"; Regex r = new Regex(string.Format("[{0}]", Regex.Escape(regexSearch))); new_FileName = r.Replace(fileName, QuoteChar); } return new_FileName; } } }