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

StackOverflow https://stackoverflow.com/questions/20519867

  •  31-08-2022
  •  | 
  •  

Вопрос

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?

Это было полезно?

Решение

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

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top