How to start a process in the same folder as its executable

后端 未结 3 843
天命终不由人
天命终不由人 2021-01-11 17:09

I\'m trying to start an application programatically, but it always runs it in the folder of my application... For example:

If my app is located in C:\\MyApp\\myapp

相关标签:
3条回答
  • 2021-01-11 17:33

    Just set the WorkDirectory property.

    process.StartInfo.WorkingDirectory = Path.GetDirectoryName(application.Filename);
    
    0 讨论(0)
  • 2021-01-11 17:54

    I guess you mean ProcessStartInfo.WorkingDirectory Property

    0 讨论(0)
  • 2021-01-11 17:55

    Use process.StartInfo.WorkingDirectory = pathToTheFolder;.

    0 讨论(0)
提交回复
热议问题