Domanda

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

È stato utile?

Soluzione

Make use of regex,

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

Regex regEx = new Regex(pattern);
string final = Regex.Replace(regEx.Replace(input, replacement), @"\s+", " ");
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top