zoukankan      html  css  js  c++  java
  • WebBrowser加载本地资源

    加载的本地资源有两种情况:

    一:加载程序集里面的资源信息

      1.加载html资源

        (1)

          StreamReader reader=Application.GetResourceStream(New Uri("path",UriKind.Relative).Stream;

          webBrowser.NavigateToString(reader.ReadToEnd());

        (2)

                   引用命名空间: Microsoft.Xna.Framework;

          StreamReader reader = new StreamReader(TitleContainer.OpenStream("pathString"));

          webBrowser.NavigateToString(reader.ReadToEnd());

        (3)

         webBrowser.NavigateToString("htmlString");

        注:为了让显示的html页面能够进行交互,就需要让webBrowser具备支持脚本语言的功能,所以需要设置webBrowser.IsScriptEnabled = true;

      2.加载图片资源

        

    二:加载程序的独立内存空间里面的资源信息

       1.加载html资源

        (1)

          VAR fe = IsolatedStorageFile.GetUserStoreForApplication());                    

          IsolatedStorageFileStream stream= fe.OpenFile("BOOK.HTML", FileMode.Open, FileAccess.Read);   

          StreamReader reader=new StreamReader(stream);             

          webBrowser.NavigateToString(reader.ReadToEnd()); 

            2.加载图片资源

          将网络图片资源保存在本地的空间上面,然后使用WebBrowser控件展示,

          ProductId:Windows phone 工程中的WMAppManifest.xml中的App节点的ProductId属性

          ContentDictionary:保存在本地存储控件的路径

          string html=""<html><head><title>title information</title></head><body>good morning </br>good afternoon</br><img width=\"300\" height=\"400\" src=\"file:///Applications/Data/{0}/Data/IsolatedStore/{1}\"></body></html>"
          html=String.Format(html,ProductId,ContentDictonary);

                    webBrowser.NavigateToString(html);

  • 相关阅读:
    C语言枚举类型(C语言enum用法)详解
    基础练习 报时助手
    怎么将CAD转JPG?教你两种CAD转JPG方法
    CAD图纸怎么看?这两种方法值得看
    某酒店建筑设计CAD施工图
    CAD怎么算面积?这种方法你要知道
    怎么将DWG转PDF?分享一个在线转换方法
    如何使用CAD删除命令?怎么删除图纸中线段
    CAD制图软件哪个好?试试这两个就知道了
    CAD制图初学入门如何学好CAD?CAD大神总结5点诀窍,必须收藏
  • 原文地址:https://www.cnblogs.com/mokey/p/2252775.html
Copyright © 2011-2022 走看看