예제 #1
0
        //读取违禁词文件
        private void readFile()
        {
            FileStream   fs = new FileStream(path, FileMode.Open);
            StreamReader sr = new StreamReader(fs);

            while (!sr.EndOfStream)
            {                               //读取一行数据进行处理
                string line = sr.ReadLine().Trim();
                //处理引号(删除后用空格作为分隔符分割数据)
                string content = line.Replace("\"", "");
                //新建Message实例,然后添加到_forbidden变量
                ForbiddenMessage message = new ForbiddenMessage(content);
                _forbiddenWords.Add(message);
            }
            sr.Close();
            fs.Close();
        }
예제 #2
0
파일: Main.cs 프로젝트: lovevv/MicroBlog
 //读取违禁词文件
 private void readFile()
 {
     FileStream fs = new FileStream(path, FileMode.Open);
     StreamReader sr = new StreamReader(fs);
     while (!sr.EndOfStream)
     {                               //读取一行数据进行处理
         string line = sr.ReadLine().Trim();
         //处理引号(删除后用空格作为分隔符分割数据)
         string content = line.Replace("\"", "");
         //新建Message实例,然后添加到_forbidden变量
         ForbiddenMessage message = new ForbiddenMessage(content);
         _forbiddenWords.Add(message);
     }
     sr.Close();
     fs.Close();
 }