我编一个!!!!可以满足要求!!
using System;
using System.Collections.Generic;
using
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using
namespace WindowsApplication7
{
public partial class Form1 : Form
{
StreamReader yan;
int i;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
yan = new StreamReader("c:\\yan.txt");
}
private void timer1_Tick(object sender, EventArgs e)
{
i++;
string readstring;
readstring=yan.ReadLine();
if (i==2)//第二行的数据
{
timer1.Enabled = false;
MessageBox.Show("第二行了,停止读取!!!!");
return;
}
if (i != 2) //第二行了
{
if (readstring == "" || readstring == null)
{
timer1.Enabled = false;
MessageBox.Show("此为空行!!文件可能读取结束!!程序停止读取!!");
return;
}
timer1.Enabled = false;
MessageBox.Show("现在读取第" + i + "行数据:" + readstring);
timer1.Enabled = true;
return;
}
}
private void button1_Click(object sender, EventArgs e)
{
timer1.Enabled = true;
}
}
}