当前位置:编程学习 > C#/ASP.NET >>

c# 中在 读取文件流时 怎样 在单击上一条 ,下一条时 逐条的显示数据呢 ,亿万火急!!!

c# 中在 读取文件流时 怎样 在单击上一条 ,下一条时  逐条的显示数据呢 
  就是 我建了一个txt文件  里面有几行数据  当我单击程序中的上一条或下一条按钮时 会显示一条信息,再单击会显示上一行或下一行的数据 
      请大家 帮帮忙 
先谢谢了!高手看到请速回帖子!!!十万火急!!!急急急!!! --------------------编程问答-------------------- 使用 StreamReader 类的 ReadLine 方法将文本文件的内容读取(一次读取一行)到字符串中。

示例:



int counter = 0;
string line;

// Read the file and display it line by line.
System.IO.StreamReader file = 
    new System.IO.StreamReader(@"c:\test.txt");
while((line = file.ReadLine()) != null)
{
    System.Console.WriteLine (line);
    counter++;
}

file.Close();
System.Console.WriteLine("There were {0} lines.", counter);
// Suspend the screen.
System.Console.ReadLine();

补充:.NET技术 ,  C#
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,