jayrrr
jayrrr

Reputation: 179

Process.Start, WorkingDirectory, start one exe from another

I hope you will get my problem, dont know if I can describe it properly in english, but I will try :)

Situation:

Problem:

So, I am still learning C#, but could there be a problem with the workingdirectory? I am so confused, because the MainProg.exe has nothing to do with my xml file, it doesnt even know its there, the only point, where I use it is when loading values into SecondProg.exe...

Inside my .cs file, I start the SecondProg via

public override void Button()
{
Process.Start("Sub1\\Sub2\\SecondProg.exe");
}

So its like, MainProg has the button, in my .cs file I tell him what to onClick. well.. its hard to describe if you're not using your native language, but I hope you get what I mean ;)

Upvotes: 1

Views: 1679

Answers (1)

jmcilhinney
jmcilhinney

Reputation: 54417

That SecondProg.exe apparently looks in its working directory for that file and fails if it doesn't find it. As such, you have to set the working directory of the new process. To do that, create a ProcessStartInfo object, set the FileName to the path of the EXE file and the WorkingDirectory to the path of the folder containing that EXE. You then pass that object as an argument when you call Process.Start.

Upvotes: 2

Related Questions