I am using listbox where I am populating the listbox with the images with the absolute uri. Now i need to save the images to my media library within my phone. But when I try:
Application.GetResourceStream(new Uri(imageurl, UriKind.absolute))
it fires an exception. Is there any way to solve this problem.
Thanks in advance.
Here's what I found as solution and it worked:
WebClient client = new WebClient();
client.OpenReadCompleted += (s, e) =>
{
if (e.Error == null)
{
MediaLibrary library = new MediaLibrary();
library.SavePicture(imageName, e.Result);
}
};
client.OpenReadAsync(new Uri(imageAbsoluteUrl, UriKind.Absolute));
If you're referencing imageswith an absolute Uri then they won't be part of the application and so therefore not accessible as a resource stream.
You'll need to download the image to get the stream directly and then write it to the media library.