2010-12-03 48 views

回答

2

可能是最接近的是:

WebRequest req = WebRequest.Create(url); // note this is IDisposable so 
             // should be in a "using" block, or 
             // otherwise disposed. 

,因爲這將處理多種協議等,但如果你的意思HTTP - 我會用WebClient;它比HttpWebRequestWebRequest實現之一)簡單得多。

如果你想要的是下載頁面:

string s; 
using(var client = new WebClient()) { 
    s = client.DownloadString(url); 
}