MS WebBrowser +嵌入式HTML资源+ res://协议 [英] MS WebBrowser + Embedded HTML Resource + res:// Protocol

查看:107
本文介绍了MS WebBrowser +嵌入式HTML资源+ res://协议的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Visual Studio项目中嵌入了一个HTML资源(helloworld.htm)。 (即,我已经为该项目添加了一个HTML文件并将其属性设置为Embedded Resource。



在同一个应用程序中,我有一个WebBrowser控件。 p>

我想指示WebBrowser控件使用 res:// protocol

但我无法弄清楚确切的格式需要使用这种类型的URL来解决嵌入式资源。



任何想法?谢谢! 解决方案

我知道这个线程已经死了,但我昨天不得不这样做,所以我做了一些研究,发现了下面的方法,使用Stream我想我会在这里发布它,以防其他人遇到相同的废话:

  Stream docStream = Assembly。 GetExecutingAssembly()。GetManifestResourceStream(NameSpace.HTMLPage.html ); 
WebBrowser.DocumentStream = docStream;

这对我没有任何修补作用,而且非常简单。我希望这对其他人有益!


I have an embedded HTML resource (helloworld.htm) inside my Visual Studio project. (Ie, I've added an HTML file to the project and set its properties to "Embedded Resource".

Within the same application I have a WebBrowser control.

I'd like to direct the WebBrowser control to display the HTML resource using the res:// protocol.

But I can't figure out the exact format needed to address an embedded resource using this style of URL.

Any ideas? Thanks!

解决方案

I know this thread is dead, but I had to do this yesterday and couldn't get any of these methods to work. So I did a little research and found the method below, using the Stream class. I thought I'd post it here just in case somebody else runs into the same nonsense:

Stream docStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("NameSpace.HTMLPage.html");
WebBrowser.DocumentStream = docStream;

This worked for me without any tinkering, and it was so simple. I hope it benefits somebody else!

这篇关于MS WebBrowser +嵌入式HTML资源+ res://协议的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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