Click here to Skip to main content
15,307,413 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
I am trying to fetch facebook profile photo using in return i am getting profile url as,how could i save this in local folder of my project.
ZurdoDev 3-Mar-15 8:21am
Where exactly are you stuck?
Haressh 3-Mar-15 23:13pm
Saving obtained facebook profile pic in local folder

1 solution

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;
Haressh 4-Mar-15 2:28am
@Member11478643 - It Worked.

Thank you for your help.Really appreciate it.
Member 11478643 9-Mar-15 3:51am
my pleasure :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900