/// <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();
    }
}

 

      

相关文章:

  • 2022-12-23
  • 2021-05-30
  • 2022-02-24
  • 2022-12-23
  • 2021-09-23
  • 2022-12-23
猜你喜欢
  • 2021-09-10
  • 2022-01-18
  • 2022-12-23
  • 2021-12-30
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案