When I try to open a .txt file it only shows its location in my textbox.
I am out of ideas:( hope you can help me…
code:
private void OpenItem_Click(object sender, EventArgs e)
{
openFileDialog1.ShowDialog();
System.IO.StringReader OpenFile = new System.IO.StringReader(openFileDialog1.FileName);
richTextBox1.Text = OpenFile.ReadToEnd();
OpenFile.Close();
}
A
StringReaderreads the characters from the string you pass to it — in this case, the file’s name. If you want to read the contents of the file, use aStreamReader: