日期:2014-05-18 浏览次数:20893 次
//定义四个数组 ArrayList number = new ArrayList(); protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string Path = Server.MapPath("info.txt"); getStr(Path); for (int i = 0; i < number.Count; i++) { Response.Write(number[i].ToString()+" | "); //这里将所有的最后一列数据取出来了,然后判断是否有重复应该很简单了 } } } //读取txt行中的每一个数据 public void getStr(string Path) { string strLine = ""; int i = 0; try { StreamReader sr = new StreamReader(Path, Encoding.GetEncoding("GB2312")); while ((strLine=sr.ReadLine()) != null) { string[] val = strLine.Split(' '); //将数据保存在ArrayList集合中 number.Add(val[3]); Response.Write("当前第"+i+"行:<br/>"); foreach (string s in val) { Response.Write(s + "<br>"); } i++; Response.Write("<hr>"); } sr.Dispose(); sr.Close(); } catch { } }
------解决方案--------------------