Saving Image in MediaLibrary

纵然是瞬间 提交于 2019-12-05 22:24:47

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!