网页内容下载
string strl="";//存储编码 WebRequest request = WebRequest.Create(txtHtmlUrl.Text.Trim());//请求资源 WebResponse response = request.GetResponse();//响应请求 Stream datastream = response.GetResponseStream();//返回数据存入流中 StreamReader reader = new StreamReader(datastream, Encoding.UTF8);//从流中读出数据
string responseFromServer = reader.ReadToEnd();//读取数据
txtContent.AppendText(responseFromServer);//添加到RichTextBox控件中
reader.Close();//关闭
datastream.Close();//关闭
response.Close();//关闭
WebClient client = new WebClient();//实例化 client.DownloadFile(txtHtmlUrl.Text, "c:\\data.html");//下载