Loading an html file in a webBrowser

trinque

Member
Joined
Jul 6, 2013
Messages
6
Programming Experience
Beginner
I am trying to load an html file in my resources folder using the webBrowser;however, I can't find out what the code is for this. I have been searching online for the past few hours and cannot seem to find anything.This is what I currently have that works but I want to load the page so that the background image will load faster.
WebKitBrowser1.DocumentText = "html source code"

Does anybody know how I could make my web browser load this html page from my resources folder?
 
There is no "resources folder". That's part of the project, not the application. The whole point of resources is that they are part of the compiled EXE, not separate files.

There are two ways to add resources in VS:

1. Add a file to your project and set its Build Action property to Embedded Resource.
2. Add the file via the Resources page of the project properties.

If you used option 1 then I recommend that you remove the file and use option 2 instead. That will allow you to access the data using My.Resources, which makes everything much neater. When you add a resource that way, VS adds a property to My.Resources, the type of which depends on the nature of the original file. I haven't checked but I would expect that an HTML file would produce a String property. In that case, assuming that the original file was named MyFile.htm, your code would be:
WebKitBrowser1.DocumentText = My.Resources.MyFile
 
If it didn't work then you did something wrong. As you haven't shown us what you did then we can only guess at what might be wrong. Did you actually check whether that resource property is type String? I did say that I hadn't. My first guess is that it's not and an exception is being thrown but your code is in the Load event handler so it's just being swallowed.
 
I moved where I had the code and it is working now. sorry for my Newbiness with visual basic, I am just starting out and thank you for helping me.
 

Latest posts

Back
Top