Search code examples
imagewindows-phone-7media-library

Saving Image in MediaLibrary


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.


Solution

  • 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));