سؤال

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

هل كانت مفيدة؟

المحلول

Make use of regex,

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

Regex regEx = new Regex(pattern);
string final = Regex.Replace(regEx.Replace(input, replacement), @"\s+", " ");
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top