Hi I was wondering if someone could help me. I would like to able to be to have my program give the user the ability to only read a certain block of code from a text document. However I would like it to be placed behind a button so it can be turned on and off. I have experimented wih different ways of doing this but nothing has made the slightest bit of difference.
This is how my code stands at the moment.
namespace filestream
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private string Read(string file)
{
StreamReader reader = new StreamReader(file);
string data = reader.ReadToEnd();
reader.Close();
return data;
}
private void btn1_Click(object sender, EventArgs e)
{
textBox1.Text = "";
DialogResult result = openFileDialog1.ShowDialog();
if (result == DialogResult.OK)
{
string data = Read(openFileDialog1.FileName);
textBox1.Text = data;
}
else
{
//do nothing
}
}
private void button1_Click(object sender, EventArgs e)
{
}
}
}
Im quite new at this so any help would be greatly appreciated.