2017-10-21 53 views
1

我在webBrowser控件中显示HTML文件(Documentation.html)的内容。 HTML文件位于资源。HTML从资源中找到C#webBroswer的图像

string htmlFile = Properties.Resources.Documentation; 
webBrowser1.DocumentText = htmlFile; 

里面有documentation.html上的图像,这将适当在任何浏览器中显示:

<img src="Resources/Image.png"> 

不幸的是,HTML文件的所有文本正常,但没有出现图像。

我可以设置图像路径的资源(如Properties.Resources.Image)或其他?

回答

2

您可以嵌入在文件documentation.html上图像的数据,如

<img alt="Embedded Image" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIA..." /> 

裁判: Embedding Base64 Images

你可以做到这一点无论是direcly或者甚至像

htmlFile .Replace("Resources/Image.png", string.concat("data:image/png;base64," + imageData))

代码