通过 HttpWebResponse 返回一个网页,然后提到网页的源文件(字符串格式),怎么在把他在Windows应用程序里显示出来呢?
HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(strUrlPage);
HttpWebResponse myResponse  = (HttpWebResponse)myRequest.GetResponse();
byte[] buf = new byte[myResponse.ContentLength]; 
Stream resStream = myResponse.GetResponseStream(); 
int intCount=0,intRead=0,intTotal=buf.Length,intUnRead=intTotal;
while(true)
{
  intCount = resStream.Read(buf, intRead, intUnRead); 
  if (intCount==0)  
    break;
    intRead=intRead+intCount;
    intUnRead=intTotal-intRead;
}
resStream.Close(); 
return Encoding.Default.GetString(buf, 0, intTotal);

解决方案 »

  1.   

    如果用WebBrowse,是否可以给出一些详细的代码呢?
      

  2.   

    http://dotnet.aspx.cc/ShowDetail.aspx?id=9D49B3EF-0F91-421B-841F-5D9A000BDA04
      

  3.   

    http://dotnet.aspx.cc/ShowDetail.aspx?id=9D49B3EF-0F91-421B-841F-5D9A000BDA04
      

  4.   

    public string source(string Site)
    {
    HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(Site);
    HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
    StreamReader sr = new StreamReader(resp.GetResponseStream(),Encoding.Default); string source = sr.ReadToEnd();
    resp.Close();
    return source;
    }TextBox控件TextBox1.Text=source("http://www.abc.com");
      

  5.   

    http://blog.csdn.net/landlordh/archive/2005/01/17/255843.aspx
      

  6.   

    思归,思归!来吧通过 HttpWebResponse 返回一个网页,然后提到网页的源文件(字符串格式)
    ----这一步是在服务器上(Windows服务里完成)
    怎么在把他在Windows应用程序里显示出来呢(以网业的形式)?
    -----这一步在客户端机器上完成我想在服务器服务中加入一个自己写的服务,侦听某个端口,然后一旦侦听到客户端请求的网业地址,服务就去下载数据,然后发送数据,客户端侦听到,就把收到的数据还源成网页!谢谢!