C# 判断文件名中是否有非法字符

if (string.IndexOfAny(System.IO.Path.GetInvalidFileNameChars()) >= 0)
{
    
//含有非法字符
}
原文地址:https://www.cnblogs.com/1971ruru/p/2101195.html