how to run exe Embedded File

sarmad

Active member
Joined
Jan 22, 2006
Messages
37
Programming Experience
1-3
hi
first sorry for my poor english

i am newcomer and any help would be great

how i can put "exe" and "pdf" file like (foxit reader) and pdf document

(myfile.pdf) in my project.......


and when i need be able to run this exe file and open pdf file with it...


so thank
 
Yes (here in a variable for clarity):

VB.NET:
[COLOR=black][COLOR=blue]Dim[/COLOR] assembly [COLOR=blue]As[/COLOR] System.Reflection.Assembly = _
    System.Reflection.Assembly.GetExecutingAssembly()
[COLOR=blue]Dim[/COLOR] resName [COLOR=blue]As[/COLOR] [COLOR=blue]String[/COLOR] = [COLOR=maroon]"windowsapplication1.file.exe"[/COLOR]
[COLOR=blue]Dim[/COLOR] stream [COLOR=blue]As[/COLOR] System.IO.Stream = assembly.GetManifestResourceStream(resName)
[/COLOR][COLOR="DarkGreen"]' and so on ...[/COLOR]
 
Dim resName As String = "windowsapplication1.file.exe"

doesnt work

this **** error happen

i want send my project to you

if there is no problem please say to me






 
Er..., the project you sent was not all that helpful. I can't find any .exe nor .pdf resources in it.
And the only code that's opening a resource stream is looking for "Runner.exe" (which was my example).

Depending on the way you add the files as resources, you have two options. I have the impression you tried to use the second option (which will only work in .NET 2.0), but with the code for the first option.
So I would recommend the second option (B) for you.

A) Following the steps I gave previously
1) Add the .exe and the .pdf to an assembly (right click in Solution Explorer on your project, choose Add Existing Item)
2) Set the Build Action to Embedded Resource
3) Use the code I gave you earlier (be sure to respect case: for instance it's "WindowsApplication1" and not "windowsapplication1" in the solution you sent me.

B) Add the files as resources in the My namespace
1) In Solution Explorer: Doubleclick on My Project -> Resources.resx
2) Choose Files
3) Choose Add Resource -> Add Existing File and add your .exe and .pdf
4) Use following code to retrieve the resources and write them to disk (you'll get help from Intellisense when using My.Resources. , I used MyExe as an example in the code below)
VB.NET:
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] f [/SIZE][SIZE=2][COLOR=#0000ff]As [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] IO.FileStream([/SIZE][SIZE=2][COLOR=#800000]"myexe.exe"[/COLOR][/SIZE][SIZE=2], IO.FileMode.Create, IO.FileAccess.Write)
[/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] buffer() [/SIZE][SIZE=2][COLOR=#0000ff]As [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Byte[/COLOR][/SIZE][SIZE=2] = [/SIZE][SIZE=2][COLOR=#0000ff]My[/COLOR][/SIZE][SIZE=2].Resources.MyExe
f.Write(buffer, 0, buffer.Length)
f.Close()
[/SIZE]
 
thanks

did you mean that i add the myfile.exe and my.pdf to resources and then

put this code in the buttonclick ?

so how i can run the exefile with pdf?

do i have to use process start(myfile.exe,mypdf.pdf)?

so i dont need to set the Build Action to "Embedded Resource" on the files?

sorry but if you can please send me a project example

so sorry
thank
 
In attachment.

PdfViewer.exe is in fact another Visual Basic .NET 2.0 WinForm Application.
The sole code for this program is in the pdf. It just shows a MessageBox with the parameter.
 

Attachments

  • EmbeddedExample.zip
    42.7 KB · Views: 67
THANKS A LOT

i learn it.and it work fine

this project is so important for me. because of that

i dont know how i can say thank you

i have new questions sorry...

1- is there a way to copy the file to the temp dir of windows and dont copy to

project location?

2- how i can show the find box (look like find in notepad) and search in my richtextbox?

3- can i play mp3 file in my project and do not stop until close the program?

much thanks
 
Last edited:
1)
VB.NET:
[COLOR=black][FONT=Courier New][COLOR=blue]Private[/COLOR] [COLOR=blue]Sub[/COLOR] runPDF()
    [COLOR=blue]Dim[/COLOR] path [COLOR=blue]As[/COLOR] [COLOR=blue]String[/COLOR] = System.IO.Path.GetTempPath
    [COLOR=blue]Dim[/COLOR] pdfName [COLOR=blue]As[/COLOR] [COLOR=blue]String[/COLOR] = path + [COLOR=maroon]"test.pdf"[/COLOR]
    [COLOR=blue]Dim[/COLOR] exeName [COLOR=blue]As[/COLOR] [COLOR=blue]String[/COLOR] = path + [COLOR=maroon]"pdfviewer.exe"[/COLOR]
    unPack([COLOR=blue]My[/COLOR].Resources.testpdf, pdfName)
    unPack([COLOR=blue]My[/COLOR].Resources.PdfViewer, exeName)
    Process.Start(exeName, pdfName)
[COLOR=blue]End[/COLOR] [COLOR=blue]Sub[/COLOR]
[/FONT][/COLOR]

For 2) and 3) I think you'd better start separate threads.
 
Back
Top