0

i am making a 'simple' program that on button click does this:

Private Sub Button4_Click(sender As Object, e As EventArgs)
    Dim proc As New System.Diagnostics.Process()

    proc = Process.Start("resources\navcoder.exe", "")
    proc.WaitForExit()
End Sub

all works fine when testing in visual studio but not once i publish and install, even if the resource folder is in the install directory.

if i change it to:

proc = Process.Start("c:\resources\navcoder.exe", "")

it works fine, but i obviuosly needs to have the folder there with the required files in it.

what am i doing wrong?

2 Answers 2

1

A lot of people seem not to realise what resources are. The whole point of adding a resource to your project is to have the data it contains compiled into your EXE. The Resources folder in your project is just a place to store the original source files. It doesn't exist as far as the application is concerned, just as your VB source code files don't exist. When you build your project, the data in those resources is compiled into your EXE so they are no longer files and can no longer be used as files.

That's why you don't embed other EXE files as resources. You could extract the resource and save it as a file first but I would recommend against that. Add a new folder to your project and add the EXE file and any dependencies to that folder and set their Build Action to Content. They will then be copied to your output folder as is. You can then execute the EXE file because it is an EXE file. You should also use Application.StartupPath as the root of the file path rather then relying on the current directory being what you think it will be.

0
0

You should always check for existance, if its a web app, would do this in the application start in the global asax. If you are running this under a different user account, check the account has permissions. Otherwise even if the directory exists, it will fail if it cant access it or does not have permissions to execute the file.

Might be able to tell you more if you give the actual exception. I.e Unauthorized or does not exist.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.