Nickon
Nickon

Reputation: 10156

Missing Path.GetInvalidFileNameChars in Silverlight

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

Upvotes: 1

Views: 366

Answers (1)

Sajeetharan
Sajeetharan

Reputation: 222582

Make use of regex,

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

Regex regEx = new Regex(pattern);
string final = Regex.Replace(regEx.Replace(input, replacement), @"\s+", " ");

Upvotes: 2

Related Questions