Reputation: 200
window.location="C:\Users\User\AppData\Local\Packages\Package-name\LocalState\package\app\screens\firstpage.html";
This gives me an access denied exception.
Upvotes: 0
Views: 150
Reputation: 7024
Windows Store apps can't use absolute file paths. The correct way to refer to local storage is with ms-appdata:///local/. The ms-appx:/// does the same for in-package contents.
However, Windows doesn't allow the app to load/refresh itself from local storage like this, so even using the right URIs you'll get an exception.
What you're really seeking to do is render dynamic HTML content within your app, for which you need to use the x-ms-webview element instead. The webview can load HTML/CSS/JS from local storage. The caveat is that it does not have access to WinRT APIs (it's sandboxed), but you can have the app and the webview communicate via it's invokeScriptAsync method (to call code in the webview) and window.external.notify (called in the webview to raise MSWebViewScriptNotify events in the app).
For details, see Chapter 4, in the section "Dynamic Content," in my free ebook, Programming Windows Store Apps with HTML, CSS, and JavaScript, 2nd Edition, page 195.
Upvotes: 1