Home All Groups Group Topic Archive Search About

trying to extract .exe from resource

Author
28 Dec 2005 1:05 PM
Nige
I have an exe embedded in my vb.net application and I'm trying to extract it
at runtime, so i can execute it and then remove it.

my code is below

strm always is Nothing

any ideas.

thanks in advance

Dim asm As System.Reflection.Assembly =
System.Reflection.Assembly.GetExecutingAssembly()

Dim resourceName As String = asm.GetName().Name + ".filename.exe"

Dim strm As System.IO.Stream = asm.GetManifestResourceStream(resourceName)

Dim buffer() As Byte = New Byte(strm.Length) {}

strm.Read(buffer, 0, CInt(buffer.Length))

strm.Close()

Dim tempName As String = System.IO.Path.GetTempFileName()

Dim fs As New System.IO.FileStream(tempName, System.IO.FileMode.Create)

fs.Write(buffer, 0, CInt(buffer.Length))

fs.Close()


--
------------------
Jesterware DVD Audio Ripper - The ultimate DVD to mp3/ogg/wav/aac Utility.
http://www.jesterware.co.uk

Author
28 Dec 2005 3:09 PM
Nige
fixed..

thanks anyway.


--
------------------
Jesterware DVD Audio Ripper - The ultimate DVD to mp3/ogg/wav/aac Utility.
http://www.jesterware.co.uk
Show quote
"Nige" <nkarn***@blueyonder.co.uk> wrote in message
news:eEoZs96CGHA.4000@TK2MSFTNGP10.phx.gbl...
>I have an exe embedded in my vb.net application and I'm trying to extract
>it at runtime, so i can execute it and then remove it.
>
> my code is below
>
> strm always is Nothing
>
> any ideas.
>
> thanks in advance
>
> Dim asm As System.Reflection.Assembly =
> System.Reflection.Assembly.GetExecutingAssembly()
>
> Dim resourceName As String = asm.GetName().Name + ".filename.exe"
>
> Dim strm As System.IO.Stream = asm.GetManifestResourceStream(resourceName)
>
> Dim buffer() As Byte = New Byte(strm.Length) {}
>
> strm.Read(buffer, 0, CInt(buffer.Length))
>
> strm.Close()
>
> Dim tempName As String = System.IO.Path.GetTempFileName()
>
> Dim fs As New System.IO.FileStream(tempName, System.IO.FileMode.Create)
>
> fs.Write(buffer, 0, CInt(buffer.Length))
>
> fs.Close()
>
>
> --
> ------------------
> Jesterware DVD Audio Ripper - The ultimate DVD to mp3/ogg/wav/aac Utility.
> http://www.jesterware.co.uk
>

AddThis Social Bookmark Button