Bit*_*ger 6 html c# resources embedded-resource
我得到了名为test.html的文件,它只是一个基本的html文件,里面有一些文字.test.html是我的c#项目中的一个资源,我有一个名为webbrowser1的webbrowser需要加载我的html文件.
那么如何将test.html加载到我的webbrowser中
我试过这个,但它不起作用:
private void button1_Click(object sender, EventArgs e)
{
webBrowser1.DocumentStream =
Properties.Resources.ResourceManager.GetStream("test.html");
}
Run Code Online (Sandbox Code Playgroud)
有解决方案吗?
我认为"test.html"不是资源的有效名称.请尝试使用"test_html".然后以下工作就好了.
private void button1_Click(object sender, EventArgs e)
{
string html = Properties.Resources.test_html;
webBrowser1.DocumentText = html;
}
Run Code Online (Sandbox Code Playgroud)
所以,如果HTML文件是
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
This is some resource HTML
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
你最终会得到

| 归档时间: |
|
| 查看次数: |
8378 次 |
| 最近记录: |