I am trying to make something that opens a file doesn't work

Mar 2 2019 8:12 PM
I am trying to make a program that opens text files and shows the text but I get an error saying that ExecuteBox does not contain a definition for text. Please help!!! Code below
 
 
void OpenFile_Click(object sender, EventArgs e)
{
Stream myStream;
OpenFileDialog OpenTxtFile = new OpenFileDialog();
void OpenFile_Click(object sender, EventArgs e)
{
OpenTxtFile.Filter = "Text|*.txt";
if (OpenTxtFile.ShowDialog() == DialogResult.OK)
{
ExecuteBox.Text = OpenTxtFile.FileName;
//FileName.Text = OpenTxtFile.SafeFileName; -- Shows file name good for multiple tabs.
if ((myStream = OpenTxtFile.OpenFile()) != null)
{
string strfilename = OpenTxtFile.FileName;
string filetext = File.ReadAllText(strfilename);
ExecuteBox.Text = filetext;
}
}
}
}

Answers (1)