/// <summary>
/// 查看是否存在
/// </summary>
/// <param name="str"></param>
/// <returns></returns>
public static bool Illegalchar(string str)
{
LoadIllegalchar();//查找到应该过滤的文件
string[] LimitedChars = LimitedChar.Split(new char[]{','}, StringSplitOptions.RemoveEmptyEntries); //去掉空字符串
foreach (string _lim in LimitedChars)
{
int _pos = str.IndexOf(_lim);
if (_pos >= 0)//如果>=0 那么此字在字符串中位置
{
return false;
}
}
return true;
}
/// <summary>
/// 获取到过滤字TXT,将其放入到字符串中
/// </summary>
public static void LoadIllegalchar()
{
string fileName = AppDomain.CurrentDomain.BaseDirectory.ToString() + "Filter.txt";
if (File.Exists(fileName))
{
//这句话就不乱码了;
StreamReader sr = new StreamReader(fileName , Encoding.GetEncoding("gb2312"));
LimitedChar = sr.ReadLine();
}
}