private void FilterText()

{
string txtPath=Request.PhysicalApplicationPath+@"modules/guestbookmanager/filter.txt";
nn=this.TextBox1.Text;
if(!File.Exists(txtPath))

{
Response.Write ("文件路径或者文件路径不存在错误信息");
}
else

{
StreamReader objReader = new StreamReader(txtPath,System.Text.Encoding.GetEncoding("gb2312"));

string sLine="";
ArrayList arrText = new ArrayList();

while (sLine != null)

{
sLine = objReader.ReadLine();
if (sLine != null)
arrText.Add(sLine);
}
objReader.Close();

foreach (string sOutput in arrText)

{
string[] strArr=sOutput.Split('|');
for (int i = 0; i < strArr.Length; i++)

{
string temp = "";
for (int j = 0; j < strArr[i].Length; j++)

{temp += "*";}
nn=nn.Replace(strArr[i], temp);
}
Response.Write(nn);
}
}
需要引用System.IO;命名空间





















































过滤xtBox1.Text如果包含有Filter.txt的过滤字符时就替换等长的*号。
需要引用System.IO;命名空间
需要引用System.IO;命名空间