怎么得到一个图片URL 用代码另存为到本地呢
如何得到一个图片URL 用代码另存为到本地呢?
我的意思是
我得到一个图片的URL 如:http://proimg.163.com/channel01/xh_300130_0623.png
用代码
通过这个URL
自动Copy到我的本地磁盘里面保存?
也就是相当于我们手动对图片点右键保存 只是换成代码自动保存
希望能给个例子看看
在此先谢谢了。。。。
------解决方案--------------------
我的意思是
我得到一个图片的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.****.net/Images/logo_****.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.****.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(); } } }