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