01/09/08 16:16
Luk3
Heilà!
Mi trovo a dover leggere delle righe di testo da un file .txt, per poi riscriverle in una textbox.
Questo codice mi lancia l'eccezione ObjectDisposeException.
Sapete come gestirla o evitarla?
Grazie
Mi trovo a dover leggere delle righe di testo da un file .txt, per poi riscriverle in una textbox.
private void button12_Click(object sender, EventArgs e) { OpenFileDialog open = new OpenFileDialog(); open.Filter = "File di Testo (*.txt)|*.txt"; if (open.ShowDialog() == DialogResult.OK) { StreamReader sr = new StreamReader(open.FileName); while (!sr.EndOfStream) { textBox1.Text = sr.ReadLine(); textBox2.Text = sr.ReadLine(); textBox3.Text = sr.ReadLine(); textBox4.Text = sr.ReadLine(); textBox5.Text = sr.ReadLine(); textBox6.Text = sr.ReadLine(); textBox7.Text = sr.ReadLine(); textBox8.Text = sr.ReadLine(); textBox9.Text = sr.ReadLine(); textBox10.Text = sr.ReadLine(); sr.Close(); } } }
Questo codice mi lancia l'eccezione ObjectDisposeException.
Sapete come gestirla o evitarla?
Grazie
aaa