HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
WebResponse resp = req.GetResponse();
StreamReader sr = new StreamReader(resp.GetResponseStream(), System.Text.Encoding.Default);
string html = sr.ReadToEnd();这样就行了,或直接用resp.GetResponseStream()就可以获得流了

解决方案 »

  1.   

    感谢您使用微软产品。 根据我的经验, 我们可以用 WebClient 类及其 DownloadFile 方法来实现这个要求.如:
             string remoteUri = "http://www.contoso.com/library/homepage/images/";
             string fileName = "ms-banner.gif", myStringWebResource = null;
             // Create a new WebClient instance.
             WebClient myWebClient = new WebClient();
             // Concatenate the domain with the Web resource filename.
             myStringWebResource = remoteUri + fileName;
             Console.WriteLine("Downloading File \"{0}\" from \"{1}\" .......\n\n", fileName, myStringWebResource);
             // Download the Web resource and save it into the current filesystem folder.
             myWebClient.DownloadFile(myStringWebResource,fileName);      
             Console.WriteLine("Successfully Downloaded File \"{0}\" from \"{1}\"", fileName, myStringWebResource);
             Console.WriteLine("\nDownloaded file saved in the following file system folder:\n\t" + Application.StartupPath.);
    更具体的说明和源码请参考下面这些资料: 
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemNetWebClientClassTopic.asphttp://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemNetWebClientClassDownloadFileTopic.asp?frame=true
    - 微软全球技术中心 技术支持 本贴子以“现状”提供且没有任何担保,同时也没有授予任何权利。具体事项可参见使用条款
    (http://support.microsoft.com/directory/worldwide/zh-cn/community/terms_chs.asp)。