Hi =)
First of all why you didn't close your stream after read a file ?)
private void button1_Click(object sender, EventArgs e)
{
openFileDialog1.Filter = "txt files (*.txt)|*.txt";
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
label2.Text = "File Open: " + openFileDialog1.FileName;
Properties.Settings.Default.url = openFileDialog1.FileName;
Properties.Settings.Default.Save();
StreamReader objstream = new StreamReader(Properties.Settings.Default.url);
richTextBox1.Text = objstream.ReadToEnd();
????????
}
After reading you must invoke Close method on objstream member.
Or it would be better if you incorporate stream initialization in using scope.
private void button1_Click(object sender, EventArgs e)
{
openFileDialog1.Filter = "txt files (*.txt)|*.txt";
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
label2.Text = "File Open: " + openFileDialog1.FileName;
Properties.Settings.Default.url = openFileDialog1.FileName;
Properties.Settings.Default.Save();
using(StreamReader objstream = new StreamReader(Properties.Settings.Default.url)){
richTextBox1.Text = objstream.ReadToEnd();
}
}