Support Forums

Full Version: Help with coding
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Help me please to do this in vb.net
1.How do i copy my resources(which is an .exe) to a specific directory and run it.

2.How can i run an .exe file or .rar which i imported into the resources of my project by pressing button .

I tried the following codes but wasnt successful.

Process.start(my.resources.filename)

Shell(my.resources.filename)

Do help me out
Here's my demo for you.

Code:
Dim resFile As Byte() = My.Resources.file
Dim WritePath as string = "MyFolderPathHere\myfile.exe"
Dim fstream As New FileStream(WritePath, FileMode.Append)
fstream.Write(resFile, 0, resFile .Length)
fstream.Close()

What we're doing here is defining a byte array from the resource named "file" as an executable i've added as a project resource, and writing those bytes to a file i'm creating in it's own path with the myfile.exe name.

Very very easy there buddy. You can also look into ByteReader and ByteWriter in the System.IO namespace if you want.

Now to run this:
Code:
Process.Start(WritePath)

This won't work:
Code:
Process.start(my.resources.filename)

Because Process.Start() doesn't take a byte array as input which is what my.resources.filename really is, it's not a string, it's a byte array.