Frage

I noticed that GetInvalidFileNameChars() method is missing in Silverlight. What is the best way to validate file names in this case?

War es hilfreich?

Lösung

Make use of regex,

string pattern = "[\\~#%&*{}/:<>?|\"-]";
string replacement = " ";

Regex regEx = new Regex(pattern);
string final = Regex.Replace(regEx.Replace(input, replacement), @"\s+", " ");
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top