当前位置:编程学习 > C#/ASP.NET >>

请问,如何将网页文件放到资源文件的包里,然后用webbrowser加载资源文件包里的网页?

我想将网页文件放到资源文件的包里,然后再用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);

--------------------编程问答-------------------- 谢谢了回复的朋友,希望有做过这样的程序的朋友分享下,分数都可以给你的 --------------------编程问答-------------------- 自己顶,请高手帮忙 --------------------编程问答--------------------
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,