Starting a program with a chosen path
Re: Starting a program with a chosen path
There's no need to set your app's CurrentDirectory.
vb.net Code:
Dim psi As New ProcessStartInfo(fileName)
psi.WorkingDirectory = folderPath
Process.Start(psi)
vb.net Code:
Dim psi As New ProcessStartInfo(IO.Path.Combine(folderPath, fileName))
psi.UseShellExecute = False
psi.WorkingDirectory = folderPath
Process.Start(psi)
One of those will do what you want, depending on what you're trying to achieve and how the app being started behaves. You just have to pass the correct folder path and file name.
Re: Starting a program with a chosen path
Re: Starting a program with a chosen path
Quote:
Originally Posted by
cuvvvie
Yes there is
No there isn't. That's what I have set the WorkingDirectory in my code examples for. It specifies the startup folder and/or current directory for the new process without your having to change the current directory for the current process.
Re: Starting a program with a chosen path
Re: Starting a program with a chosen path
Quote:
Originally Posted by
cuvvvie
Oh, I thought you meant my original code :confused:, I understand that there is no need for it in the code you gave me.
I meant exactly what I thought I meant. You must improve your mind-reading skills. ;)
Re: Starting a program with a chosen path