Display Resource File Webpage >> Form
when it comes to images etc I know how to place the resource file, but when I want to display a webpage that is saved, how do I display this onto the form?
I have copied and pasted the file to the resources, yet I noticed it looks like a text file??
Is it possible to display the file using the webbrowser control by linking it to that file, just not sure.
Thank you
Re: Display Resource File Webpage >> Form
Hi,
When you have added files to your Resources, files like Executable and Picture files are typically stored as Binary (Byte Array) whereas Text Based files are typically stored as Strings. To confirm the file storage type adopted for a particular file you can click on the file and Look at the File Type property in the Properties tab.
If your file is just a text file then you can load the WebBrowser Control using:-
vb.net Code:
WebBrowser1.DocumentText = My.Resources.YourFileResourceAsString
But, if your file is Binary then you can load the WebBrowser control using a MemoryStream:-
vb.net Code:
Dim myFileStream As New MemoryStream(My.Resources.YourFileResourceAsByteArray)
WebBrowser1.DocumentStream = myFileStream
Hope that helps.
Cheers,
Ian
Re: Display Resource File Webpage >> Form
Re: Display Resource File Webpage >> Form
Quote:
Originally Posted by
jokerfool
Its an htm file.
OK, so read what I said and choose the right option for you.
Cheers,
Ian
Re: Display Resource File Webpage >> Form
I am not understanding this.
Re: Display Resource File Webpage >> Form
Let me try again,
Go to your Project Properties (Main Menu, Project, Project Properties), click on the Resources Tab and then click on the File in question in the Resources Window. Now, from the Main Menu again, click View and then scroll down and click Properties Window. This is what will tell you, via the FileType Property, how the file has been stored as part of the Project. This is either Text or Binary. Now go back to Post #2 to finish off.
Cheers,
Ian
Re: Display Resource File Webpage >> Form
Ahhh, so I add a webbrowser and double click it and add
Code:
WebBrowser1.DocumentText = My.Resources.Antivirus_Malware
But when I press play I dont see anything, I also dont see any errors either. So it must be working, just not displaying anything. Any reason why?
Re: Display Resource File Webpage >> Form
You need to stop and think about what it is you want to do and compare that with what it is that you are actually doing.
Firstly, that fact that you did not even have a WebBrowser Control added to your project just seems a bit strange to me and yet the penny seemed to drop after my last post.
Secondly, you have just added the code I demonstrated to your project by just double clicking the WebBrowser control and pasting in the relevant code and expect things to just magically happen. When double clicking the WebBrowser control the default Event Handler Code that is added to your project is the DocumentCompleted Event. Do you know what this event does and do you know when it fires? If not then you need to do some research on that fact to understand why your code does not work. You then need to decide where you want to put the code that populates the DocumentText of the WebBrowser control.
Finally, what has a “Play Button” got to do with anything mentioned in this Thread so far? You do not need to answer that question but maybe this is where your code is supposed to go?
Cheers,
Ian
Re: Display Resource File Webpage >> Form
Thanks for being arrogant. I will pay someone to help me instead
Re: Display Resource File Webpage >> Form
This thread can now be closed thanks to people like you.
Re: Display Resource File Webpage >> Form
Quote:
Originally Posted by
jokerfool
Thanks for being arrogant. I will pay someone to help me instead
This thread can now be closed thanks to people like you.
Excuse me?
My sincere apologies for trying to help you.
Good luck in your future endeavours and I will ask the Mods to remove that ungrateful rep that you posted.
Ian