回复 6楼 yl556303
private void button1_Click(object sender, EventArgs e)
{
if(!File.Exists(@"D:\Text1.txt"))
return;
StreamReader sr = File.OpenText(@"D:\Text1.txt");
{
string s="";
while((s=sr.ReadLine())!=String.Empty)
this.textBox1.Text=s;
}
}
其中while改称if,s=sr.ReadLine()已经把字符串全都读出来了
private void button1_Click(object sender, EventArgs e)
{
if (!File.Exists(@"D:\Text1.txt"))
return;
StreamReader sr = File.OpenText(@"D:\Text1.txt");
{
string s = "";
if ((s = sr.ReadLine()) != String.Empty)
{
this.textBox1.Text = s;
}
}
}
再有问题断点调试吧