自动从网站上面下载文件 .NET把网站图片保存到本地

原文发布时间为:2009-11-19 —— 来源于本人的百度文章 [由搬家工具导入]

自动从网站上面下载文件 .NET把网站图片保存到本地简单范例:
这个范例是把百度联盟这个logo保存到根目录下面,当执行程序后,你刷新一下根目录,即可看到logo已经被自动下载到本地,并且命名为baidu.gif。

代码很短,自己可以根据需要进行修改:

  protected void Page_Load(object sender, EventArgs e)
{
string fromURL = "http://www.baidu.com/img/lm.gif";
string fileName = "baidu.gif";
string savePath =  Server.MapPath(fileName);
WebClient myWebClient = new WebClient();
myWebClient.DownloadFile(fromURL,savePath);
}
原文地址:https://www.cnblogs.com/handboy/p/7158363.html