图像文件从网页的网址复制到本地文件夹? [英] Copy image file from web url to local folder?

查看:124
本文介绍了图像文件从网页的网址复制到本地文件夹?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对图像的网页的URL。例如, http://testsite.com/web/abc.jpg 。我想复制网址在我的本地文件夹C:\\影像\\;而且,当我复制该文件到文件夹中,我不得不重新命名图像以C:\\影像\\ xyz.jpg。

I have a web URL for the image. For example "http://testsite.com/web/abc.jpg". I want copy that URL in my local folder in "c:\images\"; and also when I copy that file into folder, I have to rename the image to "c:\images\xyz.jpg".

我们怎样才能做到这一点?

How can we do that?

推荐答案

请求图像,并将其保存。例如:

Request the image, and save it. For example:

byte[] data;
using (WebClient client = new WebClient()) {
  data = client.DownloadData("http://testsite.com/web/abc.jpg");
}
File.WriteAllBytes(@"c:\images\xyz.jpg", data);

这篇关于图像文件从网页的网址复制到本地文件夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆