Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Compiling also html files with the app

Status
Not open for further replies.

bclt

Programmer
Mar 13, 2005
363
GR
Hi,

is there any way to compile in the exe some web pages? So when the app launches the webbrowser in it will display one page, e.g. the index.htm

Tnx
 
Can you give me an example on that ?
This you tell me sounds good but i've no idea!

Tnx
 
I mean how to access it with the resources.
 
The joy of the Tek-Tips forum is that there is a search function. Now if you were to type in "resource" and hit search, you would get a list of threads where people were talking about just this.

In one thread although it's titled something about icons, a quick glance shows that the poster is wondering about embedding a file into his application. One of the posts in that thread has a link to this site: where they discuss how to embed files and how to access them.

-Rick

----------------------

[monkey] I believe in killer coding ninja monkeys.[monkey]
[banghead]
 
Tnx Rick I got if working. Let me ask something else..

1. As i embed an exe file, how can i execute it?
Code:
Dim executing_assembly As System.Reflection.Assembly = System.Reflection.Assembly.GetEntryAssembly()
Dim my_namespace As String = executing_assembly.GetName().Name.ToString()

  'i'm stuck on this:

Dim xxx As ...? = executing_assembly.GetFile(my_namespace + ".file.exe")

Also tried "process.start(xxx)" , but nothing.


2. Suppose i make an index page (htm) and in a folder e.g. "/htms" i have the files (htms) that they fill the frames in the index.htm.
Even embedding the needed files the browser says: "blankhtms/blabla1.htm", "blankhtms/blabla12.htm" etc in the frames. Tried to create a folder "blankhtms" and put the files in it but still says the same !!


Any help on these issues ?

Tnx alot
 
1) You could try using a stream to write the file to disk then use process start. I'm not sure if there is a way to execute it strictly as an imbedded resource.

2) No idea on what you are saying.

-Rick

----------------------

[monkey] I believe in killer coding ninja monkeys.[monkey]
[banghead]
 
I try once more about the 2nd thing ..

in the form i drag an explorer. This is code:

Code:
    Dim executing_assembly As System.Reflection.Assembly = System.Reflection.Assembly.GetEntryAssembly()
   
    Dim my_namespace As String = executing_assembly.GetName().Name.ToString()


    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load


        Dim text_stream1 As Stream = executing_assembly.GetManifestResourceStream(my_namespace + ".index.htm")
        If Not (text_stream1 Is Nothing) Then
            Dim stream_reader1 As New StreamReader(text_stream1)
            WebBrowser1.DocumentText = stream_reader1.ReadToEnd()
            stream_reader1.Close()
        End If
    End Sub

The browser's page is "index.htm". In that page i have a link to "a1.htm". Of course i added the "a1.htm" in the resources... but as i click the link in the index page, the browser says "blanka1.htm". It should display the a2.htm page

What's wrong?
Tnx

 
You may need to actually move the files from the resources to the hard drive so that the links in the files work correctly. write the files to:

Code:
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)

If you load a1.htm into a stream and send it to a browser, it will load fine, but the link to a2.htm doesn't know where to look for a2.htm because it is still wrapped up by the application.

-Rick

----------------------

[monkey] I believe in killer coding ninja monkeys.[monkey]
[banghead]
 
Used this but not working

File.Copy(text_stream1.ToString(), Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData))

The "text_stream1.ToString()" returns "System.IO.UnmanagedMemoryStream"

How do i copy the "a1.htm" to the disk?
 
You'll need to open a file stream I beleive. I can't keep all of the steam names straight. Anyways, open the file stream and write the text stream.read to is.

-Rick

----------------------

[monkey] I believe in killer coding ninja monkeys.[monkey]
[banghead]
 
I'll try the way you tell me. Just made a thought that i think i'll be prevented from coping the file to the disk:

Is there a way to get the url as i click a link in the browser? (e.g. "/a1.htm")So with this code: "webbrowser1.documenttext=executing_assembly.GetManifestResourceStream(my_namespace + "." & MYPAGE)"
where MYPAGE is "a1.htm
 
Is there a way to get the url as i click a link in the browser?

Not that I know of. Atleast, not that the browser could resolve back to the page in the resources collection.

-Rick

----------------------

[monkey] I believe in killer coding ninja monkeys.[monkey]
[banghead]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top