using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.IO;
namespace prjDownLoad
{
class Program
{
static void Main(string[] args)
{
//Version1.0
//使用WebClient来下载
WebClient wc = new WebClient();
//直接使用下载文件的方法,
//只需要指定要下载的Url,和保存的文件名就可以了。
wc.DownloadFile("http://blog.sina.com.cn/dalishuishou", "c:\\aa.html");
//简单了点,很多控制也没法做。
//另外一个类似的方法是DownloadData
//这个方法得到的是个byte数组
byte[] bs = wc.DownloadData("http://blog.sina.com.cn/dalishuishou");
//收到以后,当然可以把byte数组存下来或用网络流发送出去。
FileStream fs = new FileStream("c:\\aa.txt", FileMode.Create, FileAccess.Write);
fs.Write(bs, 0, bs.Length);
fs.Flush();
fs.Close();
}
}
}
转摘自:http://blog.sina.com.cn/s/blog_49458c270100gpxk.html