gpt4 book ai didi

c# - BitmapSource 指向本地文件

转载 作者:太空狗 更新时间:2023-10-30 00:43:30 28 4
gpt4 key购买 nike

为 Metro Style 应用程序实现本地缓存的最佳模式是什么,以便可以在应用程序在线使用时在后台缓存图像并在应用程序离线时提供图像?

我们如何在发现无法访问互联网时将 BitmapSource 设置为本地文件?使用 new Uri(localpath, UriKind.Absolute) 不起作用。

最佳答案

图像是否已下载?如果是,它们是否在“本地”文件夹中?

如果是这样,您可以从这样的路径构建一个 BitmapImage

var m_Image = new BitmapImage(new Uri("ms-appdata:///local/" + ImageFileName));

编辑

如果您的文件作为“从未访问过且无法下载任何东西”的备用文件存储在包中,则 Uri 将类似于

var m_Image = new BitmapImage(new Uri("ms-appx:///Assets/" + FallBackImageFileName));

关于c# - BitmapSource 指向本地文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10934102/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com