C#: How to load an internal .html file resource into a webbrowser control?
10,838
I think "test.html" is not valid name for resource. Try using "test_html" instead. Then the following works just fine.
private void button1_Click(object sender, EventArgs e)
{
string html = Properties.Resources.test_html;
webBrowser1.DocumentText = html;
}
So if HTML file is
<!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>
You'll end up with
Author by
Bitcoin Blogger
Updated on June 26, 2022Comments
-
Bitcoin Blogger almost 2 years
I got the file named test.html which is just a basic html file with some text in it. The test.html is a resource in my c# project, and I got a webbrowser named webbrowser1 that needs to load my html file.
So how to load the test.html into my webbrowser
I tried this, but it doesn't work:
private void button1_Click(object sender, EventArgs e) { webBrowser1.DocumentStream = Properties.Resources.ResourceManager.GetStream("test.html"); }
Any solutions please?
-
Mike over 2 yearsThank you @tdy for the edits. This was my first posting to stackoverflow.