muffinresearch
MIS
Hi I want to read a text file and then put the text into a textbox.
what doesn't seem to be possibleis how to access a variable outside of the static. e.g. textBox1.Text = S; isn't right!!!
Here is the code - any ideas or alternative suggestions wouldbe greatly appreciated.
[STAThread]
static void Main()
{
//Get the text from the AUP.txt file
try
{
Fileread();
}
catch (Exception)
{
MessageBox.Show("The file does not exist!");
}
Application.Run(new Form1());
}
static void Fileread()
{
StreamReader SR;
string S;
SR=File.OpenText("AUP.txt");
S=SR.ReadToEnd();
SR.Close();
textBox1.Text = S;
}
what doesn't seem to be possibleis how to access a variable outside of the static. e.g. textBox1.Text = S; isn't right!!!
Here is the code - any ideas or alternative suggestions wouldbe greatly appreciated.
[STAThread]
static void Main()
{
//Get the text from the AUP.txt file
try
{
Fileread();
}
catch (Exception)
{
MessageBox.Show("The file does not exist!");
}
Application.Run(new Form1());
}
static void Fileread()
{
StreamReader SR;
string S;
SR=File.OpenText("AUP.txt");
S=SR.ReadToEnd();
SR.Close();
textBox1.Text = S;
}