我是个C#新手,今天才是学的3的天!!!遇到了问题!

读取HTML源代码时,找到了个例子,用Stream读取出来,但byte保存不下,又找了个解决的方法:

byte[] buf = new byte[1024];
   string test = "";
   int count = 0;
   HttpWebRequest request = (HttpWebRequest) WebRequest.Create("http://www.163.com");
   HttpWebResponse response = (HttpWebResponse) request.GetResponse();
   Stream resStream = response.GetResponseStream();
   while(true)
   {
    count = resStream.Read(buf,0,buf.Length);
    //读取完成后退出循环
    if(count<=0)
     break;
    //将读取的字节数转换为字符串
    test+=Encoding.ASCII.GetString(buf,0,count);
   }

现在字符串test便保存了完全的HTML了,以此记录下来!!!

由于我是新手,还望哪位大虾有更好的办法,不吝赐教!!!