夏雷

积极人生,努力加油!
WebClient读取网页

WebClient client = new WebClient();
Stream stream
= client.OpenRead("http://www.microsoft.com/");
StreamReader sr
= new StreamReader(stream, System.Text.Encoding.UTF8);
string str = sr.ReadLine();
string returnvalue = string.Empty;
while (str != null)
{
returnvalue
+= str;
str
= sr.ReadLine();
}

 

当然WebClient远比这个强大,更多功能查看Msdn:http://msdn.microsoft.com/zh-cn/library/system.net.webclient(VS.80).aspx

posted on 2008-12-02 15:49  夏雷  阅读(297)  评论(0编辑  收藏  举报