C# 读取txt文件

   public static List<int>  GetPage()
        {
            string strpath = @"D:\test.txt";
            FileStream fs = new FileStream(strpath, FileMode.Open, FileAccess.Read);
            StreamReader sr = new StreamReader(fs, Encoding.Default);
            sr.BaseStream.Seek(0, SeekOrigin.Begin);
            string str = sr.ReadLine();
            while (str != null)
            {
                      str = sr.ReadLine();
            }
            sr.Close();
            fs.Close();
            return ListPage;
        }

posted @ 2012-11-29 18:06  息晴海  阅读(256)  评论(0编辑  收藏  举报