将图像保存在 MediaLibrary 中
我正在使用列表框,用具有绝对 uri 的图像填充列表框。现在我需要将图像保存到手机内的媒体库中。但是当我尝试时:
Application.GetResourceStream(new Uri(imageurl, UriKind.absolute))
它会引发异常。有什么办法可以解决这个问题吗?
提前致谢。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是我找到的解决方案并且有效:
Here's what I found as solution and it worked:
如果您使用绝对 Uri 引用图像,那么它们将不会成为应用程序的一部分,因此无法作为资源流进行访问。
您需要下载图像以直接获取流,然后将其写入媒体库。
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.