Use local images in Webbrowser control

前端 未结 4 515
情深已故
情深已故 2020-11-29 13:06

I\'m using a Webbrowser Control in my Wp7 app, but I can\'t seem to put images that are in the App directory, in the webbrowser.

I\'ve put some images in a folder in

4条回答
  •  悲哀的现实
    2020-11-29 13:55

    On Windows Phone 8, where some WinRT classes are available, one can get a filesystem path of your app's isolated storage. So the absolute URL to a file in IsoStorage would be:

    string URL = "file://" +
        Windows.Storage.ApplicationData.Current.LocalFolder.Path +
        "\\folder\\filename.png";
    

    The WebBrowser control takes such URLs in a NavigateToString()'d HTML alright. Or you can designate IsoStorage as base and use relative URLs throughout. isostore: URLs don't work, I've tried. Neither do ms-appx://local/.

    For completeness' sake, you can very similarly get a filesystem path to your app's resources. That'd be Windows.ApplicationModel.Package.Current.InstalledLocation.Path.

提交回复
热议问题