首先看我的源代码:
WebClient client = new WebClient();
String url = "http://localhost";
client.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)");
try
{
Stream data = client.OpenRead(url);
if (data == null)
throw new WebException("Cannot browse the url...");
StreamReader reader = new StreamReader(data);
string s = reader.ReadToEnd();
textBox1.Text = s;
data.Close();
reader.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
当我运行我的应用程序时,它将在此操作期间冻结。
我的代码的哪一部分是错误的?