C#读取txt文件

StreamReader sr = new StreamReader(@"E:\weather.txt", Encoding.GetEncoding("GB2312"));
            string line;
            while ((line = sr.ReadLine()) != null)
            {
                line = line.Substring(1);
                string[] str = line.Split('\t');
                CityCode cityCode = new CityCode();
                    cityCode.cc_Id = str[1];
                    cityCode.cc_Name = str[2];
                    cityCode.cc_ParentId = str[3];
                    int count = _CityBLL.GetInsertCityCode(cityCode);
                    //this.txtshow.Text += "str[" + i + "]:" + str[i];
                    //this.txtshow.Text += line + "\n";
                this.txtshow.Text += count.ToString();
            }

posted @ 2013-07-29 22:34  ◆紅袖  阅读(194)  评论(0编辑  收藏  举报