当第一个人读取一个txt文件之后,把他读取的txt文件内容放在缓存中,第二个人在读取的时候 不需要在读取txt文件而是利用缓存,这个怎么实现?
/*********************此方法是第一个人读取txt文件的方法*****************************/        public string filter(string str)
        {            string txtPath = Server.MapPath(" ~/Xml/filter.txt");
            str = this.TextBox1.Text;
            if (!File.Exists(txtPath))
            {
                
                Response.Write("<script   language=JavaScript> alert('文件路径或者文件路径不存在错误信息.!');</script>");            }
            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 += "*"; }
                        str = str.Replace(strArr[i], temp);
                    }
                    return str;                }
            }
            return str;
        }
急。求帮助

解决方案 »

  1.   

    你把读到的文件用DATASET接受到!然后定义全局的dataset变量!
      

  2.   

    不知道......
    我太菜了.没想过这个问题
    暂时想到的是丢到application[""]里面
      

  3.   

     DataSet ds = new DataSet();
            ds.ReadXml(Server.MapPath("XMLFile/XMLFile.xml"));
            if (ds.Tables.Count > 0)
            {
                this.Repeater1.DataSource = ds.Tables[0].DefaultView;
                this.Repeater1.DataBind();
            }
    类似上面那样的!具体做法自己弄!只能给你提供思想!