如何将File.html从资源加载到WebBrowser组件中? [英] How to load File.html from resources into WebBrowser component?

查看:67
本文介绍了如何将File.html从资源加载到WebBrowser组件中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望问题清楚..
谢谢.

I hope the question is clear..
Thanks.

推荐答案

您并没有确切地说出您遇到的困难,所以这是整个过程:

1)确保File.html包含在构建中.
将生成操作"属性设置为嵌入式资源".

2)获取资源名称
You don''t say exactly what you''re having difficulty with, so here is the whole process:

1) Make sure File.html is included in the build.
Set the "Build Action" property to "Embedded Resource".

2) Get the name of the resource
string[] a = Assembly.GetEntryAssembly().GetManifestResourceNames();
foreach ( string s in a ) Debug.WriteLine( "\t" + s );



3)提取资源:



3) Extract the resource:

string html = null;
using ( var s = Assembly.GetExecutingAssembly()
    .GetManifestResourceStream( "[name of resource.html]" ) )
using ( var r = new StreamReader( s ) )
    html = r.ReadToEnd();



4)加载WebBrowser控件:



4) Load in WebBrowser control:

webBrowser1.DocumentText = html;



尼克



Nick


这篇关于如何将File.html从资源加载到WebBrowser组件中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆