首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

怎么得到一个图片URL 用代码另存为到本地呢

2012-02-15 
如何得到一个图片URL 用代码另存为到本地呢?我的意思是我得到一个图片的URL 如:http://proimg.163.com/cha

如何得到一个图片URL 用代码另存为到本地呢?
我的意思是
我得到一个图片的URL 如:http://proimg.163.com/channel01/xh_300130_0623.png

用代码 
通过这个URL  
自动Copy到我的本地磁盘里面保存?  
也就是相当于我们手动对图片点右键保存 只是换成代码自动保存
希望能给个例子看看 
在此先谢谢了。。。。


[解决办法]

C# code
    WebClient wc = new WebClient();     wc.DownloadFile(Url, filePath);
[解决办法]
C# code
WebClient   oWebClient   =   new   WebClient();//声明     oWebClient.DownloadFile("http://www.csdn.net/Images/logo_csdn.gif",   "d:\1.gif");//下载     oWebClient.Dispose();//释放
[解决办法]
C# code
using System;using System.Collections.Generic;using System.Text;using System.Security.Cryptography; namespace ConsoleApplication24{    class Program    {        static void Main(string[] args)        {            System.Net.WebClient wb = new System.Net.WebClient();            byte[] b=wb.DownloadData("http://profile.csdn.net/johnwoo85/picture/2.jpg");            System.IO.FileStream fs = new System.IO.FileStream(@"c:\aa.jpg", System.IO.FileMode.Create);            fs.Write(b, 0, b.Length);            fs.Close();        }           }} 

热点排行