BitmapSource points to a local file

What is the best example for implementing a local cache for the Metro Style application so that images can be cached in the background when the application is used online and serves to view images when the application is turned off?

How to install BitmapSource in a local file, detecting lack of Internet access? using the new Uri (localpath, UriKind.Absolute) does not work.

+4
source share
1 answer

Are images uploaded? If so, are they in the Local folder?

If so, you can build a BitmapImage from a path like this

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

EDIT

If your file is stored in a package as “never had access and cannot load anything” in standby mode, Uri will be something like

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

Source: https://habr.com/ru/post/1416595/


All Articles