Change the working directory of a running process with C#

Viewed 10051

I do not know if this is even possible without breaking/crashing the process but is there a way to change the working directory of a System.Diagnostics.Process like you would when executing the cd (change directory) command from the cmd.exe command line interface?

2 Answers

You may set the working directory of the process with

myProcess.StartInfo.WorkingDirectory = "dir". 

Documentation here.

As per MSDN, there is only one function which can change current folder, SetCurrentDirectory and it has single string parameter, so the change is for current process only.

Related