将Facebook图像保存到本地文件夹 [英] Save Facebook image to local folder

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

问题描述

我正在尝试使用asp.net获取facebook个人资料照片作为回报我正在获取个人资料网址http://graph.facebook.com/picture.So,how我可以将其保存在我的项目的本地文件夹中。

I am trying to fetch facebook profile photo using asp.net in return i am getting profile url as http://graph.facebook.com/picture.So,how could i save this in local folder of my project.

推荐答案

私人字符串getimage(字符串网址)

{

string remoteImgPath = url;

Uri remoteImgPathUri = new Uri(remoteImgPath);

string remoteImgPathWithoutQuery = remoteImgPathUri.GetLeftPart(UriPartial.Path);



string file = Path.GetFileName(remoteImgPathWithoutQuery);

string fileName = file.Replace(file,profile_img_+ Userid);



string localPath = AppDomain.CurrentDomain.BaseDirectory +content\\uploads\\profile\\+ fileName +。jpg;

WebClient webClient = new WebClient();

webClient.DownloadFile(远程eImgPath,localPath);

返回localPath;

}
private string getimage(string url)
{
string remoteImgPath = url;
Uri remoteImgPathUri = new Uri(remoteImgPath);
string remoteImgPathWithoutQuery = remoteImgPathUri.GetLeftPart(UriPartial.Path);

string file = Path.GetFileName(remoteImgPathWithoutQuery);
string fileName = file.Replace(file, "profile_img_" + Userid);

string localPath = AppDomain.CurrentDomain.BaseDirectory + "content\\uploads\\profile\\" + fileName+".jpg";
WebClient webClient = new WebClient();
webClient.DownloadFile(remoteImgPath, localPath);
return localPath;
}


这篇关于将Facebook图像保存到本地文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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