hi everybody
i just wanna ask why is this windows application code read the file once ?
when i click the button it displays the text once..
why isn't be repeated?

 private void button1_Click(object sender, EventArgs e)
    {
        string filename = "c:\\flights.txt";
        FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read);
        StreamReader sr = new StreamReader(fs);
        textBox1.Text = sr.ReadToEnd();
        sr.Close();


    }

thanx

Edited 3 Years Ago by Reverend Jim: Fixed formatting

textBox1.Text = sr.ReadToEnd(); you say remove the text in the textbox1 then put instead the text in the file if you need to append it use textBox1.Text += sr.ReadToEnd();

What your code is actually doing is :

open a textfile
read the whole text
fill a textbox with the text
close a textfile

Do yo see any repetition here? I don't. You fill the textbox with the same text every time you click your button.

This question has already been answered. Start a new discussion instead.