Jef Patat
July 12th, 2006, 03:02 PM
Hi guru's,
at the moment I made this simple application with only one textbox and one button. When the button is pressed a file is downloaded and displayed in the textbox.
Everything runs fine but I would like to display messages indicating what operation is currently taking place ie , connecting , requesting, receiving..etc so that one can identify at which stage the connection is. How can I do this?
this is the simple code in button1_click:
try
{
WebClient client = new WebClient();
Stream data = client.OpenRead("http://ichart.finance.yahoo.com/table.csv?s=MFE&d=6&e=9&f=2006&g=d&a=9&b=7&c=2005&ignore=.csv"); StreamReader reader = new StreamReader(data);
string str = "";
str = reader.ReadLine();
while (str != null)
{
textBox1.AppendText(str + Environment.NewLine);
textBox1.SelectionStart = textBox1.Text.Length;
textBox1.ScrollToCaret();
str = reader.ReadLine();
}
data.Close();
}
catch (WebException exp)
{
MessageBox.Show(exp.Message, "Exception");
}
Thanks in advance
at the moment I made this simple application with only one textbox and one button. When the button is pressed a file is downloaded and displayed in the textbox.
Everything runs fine but I would like to display messages indicating what operation is currently taking place ie , connecting , requesting, receiving..etc so that one can identify at which stage the connection is. How can I do this?
this is the simple code in button1_click:
try
{
WebClient client = new WebClient();
Stream data = client.OpenRead("http://ichart.finance.yahoo.com/table.csv?s=MFE&d=6&e=9&f=2006&g=d&a=9&b=7&c=2005&ignore=.csv"); StreamReader reader = new StreamReader(data);
string str = "";
str = reader.ReadLine();
while (str != null)
{
textBox1.AppendText(str + Environment.NewLine);
textBox1.SelectionStart = textBox1.Text.Length;
textBox1.ScrollToCaret();
str = reader.ReadLine();
}
data.Close();
}
catch (WebException exp)
{
MessageBox.Show(exp.Message, "Exception");
}
Thanks in advance