简体   繁体   中英

Load html in windows strore app from appdata folder

I'm developing windows store app using javascript, html5 and C#. I have developed functionality which downloads zip from web and extracts it to "AppData" folder in "C" drive. That zip file has HTML files. So my question is, I want to display that html in windows app.

I'm able to load html from web in iframe but not from local drive. I also tried to do it by giving absolute path in iframe but not working.

Use webbrowser.NavigateToString("parameter"). Your question is a possible duplicate: Local HTML File - WebBrowser - Windows phone 7

Basically, StoreApp's WebView can load the local resource from your app's local storage. "app's local storage" means.. Windows.Storage.Current.ApplicationData.Current.LocalFolder, etc.

If the resources are located outside of your app's local storage, you have 2 options:

  1. Copy the all resources to your local storage.
  2. Create a 'stream' that have all required resources, then give the stream to webview.

1 is easy. To refer your html resource, use following syntax.

  • ApplicationData.Current.LocalFolder - "ms-appdata:///local/hogehoge.html"
  • ApplicationData.Current.TemporaryFolder - "ms-appdata:///temp/foobar.html"
  • App packages file (like Asset) - "ms-appx-web:///Assets/boee.html"

2 is complicated. Below is an example for 2.

XAML WebView control sample

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM