webview - Web view UWP not loading files in the machine -


can open html file on c drive or on location using web view in uwp?

i using following code not working:

  uri targeturi = new uri("c:/users/user/pictures/files/forms/dac36cac-5d83-4fae-bf4f-112361b719ea/index.html");   browser.navigate(targeturi); 

in uwp files have limited access permission. default app can access application install directory , data locations. additional locations require special capabilities. more details file access permission please reference this document.

you can gain access files , folders on removable device calling file picker (using fileopenpicker , folderpicker) , letting user pick files , folders app access. learn how use file picker in open files , folders picker.

according code snippet, want access html file inside picture folder. accessing file in picture folder please reference files , folders in music, pictures, , videos libraries. pay attention on capabilities page, select libraries app manages. correct way open file , show in webview may follows:

 storagefolder storagefolder = await knownfolders.getfolderforuserasync(null /* current user */, knownfolderid.pictureslibrary);  storagefile indexfile = await storagefolder.getfileasync("index.html");/*change file path inside picture folder*/  browser.navigatetostring(await fileio.readtextasync(indexfile)); 

you may find used navigatetostring method. navigate(uri) method can not navigate file path directly. load uncompressed , unencrypted content app’s localfolder or temporaryfolder data stores, use navigate method uri uses `ms-appdata scheme, html content in app package using ms-appx-web scheme. example:

webview1.navigate("ms-appx-web:///help/about.html"); 

more details please reference "navigating content" of webview. , scenario 5 of official sample provide samples navigating file can reference.


Comments

Popular posts from this blog

inversion of control - Autofac named registration constructor injection -

verilog - Systemverilog dynamic casting issues -

ios - Change Storyboard View using Seague -