I am using a web browser control that display html page in window form now I want to embed html and javascript files and css files as resource.
2 Answers
- Add your resource files - HTML, CSS, JS files etc. to your Visual Studio project.
- Select the file and goto Properties window for that file by pressing F4.
- Set the "Build Action" property to "Embedded Resource"
- Re-compile the application
- Use the following answer to get the embedded resource - https://stackoverflow.com/a/3314213/10458
PS: If you have a default namespace set in your project's properties, then you will have to prefix that to the file-name. For example if your file-name is File1.html and your default namespace is MyCompany.MyProject then you will have to use GetManifestResourceStream("MyCompany.MyProject.File1.html").
3 Comments
mracoker
I have css in my html and the web browser control seems to be ignoring it. More specifically I have css that will give my divs rounded corners...
noelicus
If you embed a javascript file as a resource then how do you refer to it from the embedded html?
jkamdjou
better than the microsoft documentation
Try using res: protocol. For example
res://C:\path\to\exe_or_dll\project.exe/helloworld.htm