How can i make it so that when i load my form, it loads a .exe file along with it that is in my Resource folder? Thanks
Printable View
How can i make it so that when i load my form, it loads a .exe file along with it that is in my Resource folder? Thanks
Is this possible or no ?
I don't know of any clean way to do this. But this will work assuming you added the exe into your resources:
vb.net Code:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim tempFileName As String = System.IO.Path.GetTempFileName() & ".exe" Using fs As New FileStream(tempFileName, FileMode.Create) fs.Write(My.Resources.exeNameHere, 0, My.Resources.exeNameHere.Length) End Using Process.Start(tempFileName) End Sub
i get FileStream is not defined
For my current app, I added as a resource, the CHM help file, so that in case the copy distributed with the appilcation is lost, it can be re-written to disk. Here is the code that does that:
vb.net Code:
Dim Writer As New IO.FileStream(Application.StartupPath & "\filename.chm", IO.FileMode.Create) Writer.Write(My.Resources.RESOURCE-NAME-HERE, 0, My.Resources. RESOURCE-NAME-HERE.Length) Writer.Close()
Change the chm to exe and see what you get.
Edit: I see that my code is the same as ForumAccount's code. Try adding the Close function, though. In addition, I also have "Imports System.Deployment.Application" at the top of my code.
Ugh no luck its ok i changed my mind, thx for the help both of you ! =]