haddow64
haddow64

Reputation: 674

C# using Process.Start for exe in a sub folder launches in same folder as launching exe

I'm having issues with a self written application updater and when I launch the main program (in a sub folder) from the updater using Process.Start:

Folder Structure:
\Updater\
\Updater\Updater Workspace\
\Updater\Application\

The updater launches checks the version of the application in \Updater\Application\ compares it to the latest version (updates if necessary) and launches application.exe in \Updater\Application\

The application.exe on launch does a check for a user.prefs file and if its not found automatically creates this in \Updater\ instead of \Updater\Application\

Why wold process.start spawn the process in the same directory as the launching exe?

Upvotes: 0

Views: 1713

Answers (1)

ken2k
ken2k

Reputation: 48985

Why wold process.start spawn the process in the same directory as the launching exe?

Unless you specified another directory, the working directory of the spawn process inherits from the parent process.

You can change this behavior by specifying a ProcessStartInfo parameter to Process.Start.

See Process.Start(ProcessStartInfo) and ProcessStartInfo.WorkingDirectory

Upvotes: 2

Related Questions