Convert To Legal File Name
using System; using System.Collections.Generic; using System.Text; using System.Diagnostics; using System.Windows.Forms; using System.Text.RegularExpressions; using System.IO; using System.Drawing.Imaging; using System.Reflection; namespace SuchSofts.OpenImage.Lib.Operation { internal class CommonOperations { public static string ConvertToLegalFileName(string name) { //replace \ / : * ? " < > | with # Regex regexCharFilter = new Regex("[\\u005C|/|:|\\u002A|\\u003F|\"|<|>| \\u007C]"); string fileName = regexCharFilter.Replace(name, "#"); string old = fileName; if (fileName == "") { fileName = "#"; } return fileName; } } }