为什么我的效率这么慢?
HttpWebRequest wr = (HttpWebRequest)HttpWebRequest.Create(textURL.Text);
wr.ContentType = "application/x-www-form-urlencoded";
wr.Accept = "*/*";
wr.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)";
HttpWebResponse myHttpWebResponse = (HttpWebResponse)wr.GetResponse();
StreamReader oStream = new StreamReade(myHttpWebResponse.GetResponseStream(), System.Text.Encoding.Default);
string res = oStream.ReadToEnd();
MatchCollection Matches = Regex.Matches(res, "src=(\\S*)\\.jpe?g", RegexOptions.ExplicitCapture | RegexOptions.IgnoreCase);
if (!Matches.Count.Equals(0))
{
foreach (Match NextMatch in Matches)
{
//NextMatch.Value就是一个jpg图片的地址
System.Net.WebClient webClient = new System.Net.WebClient();
System.IO.Stream stream = webClient.OpenRead(NextMatch.ToString().Substring(5));
this.pictureBox.Image = Image.FromStream(stream);
stream.Dispose();
break;
}
}
功能很简单,就是单击button之后,在pictureBox显示这个网址的jpg图片,功能可以实现,可是单击后速度很慢,这是为什么??求点指教~谢谢~