inohilog

/var/log/inohiro.log

HttpWebResponse(Request) と WebClient

HttpWebResponse(Request) と WebClient、どっちが優れているのでしょうかね。
Webページを読む(HTMLをひっぱる)だけならWebClientが簡単。

HttpWebRequest & HttpWebResponse

string url = "http:/d.hatena.ne.jp/InoHiro/";

HttpWebRequest request = ( HttpWebRequest )WebRequest.Create( url );
HttpWebResponse response = ( HttpWebResonse )request.GetResponse();

using( Stream stream = response.GetResponseStream() )
{
    using( StreamReader reader = new StreamReader( stream ) )
    {
        Console.WriteLine( reader.ReadToEnd() );
    }
}

WebClient

WebClient client = new WebClient();
Console.WriteLine( client.DownloadString( "http:/d.hatena.ne.jp/InoHiro/" ) );


でかいファイルのダウンロードとか、時間計ってみるかな。