Process.Start() not starting the .exe file (works when run manually)

后端 未结 3 1454
刺人心
刺人心 2021-02-13 12:35

I have an .exe file that needs to be run after I create a file. The file is successfully created and I am using the following code to run the .exe file

3条回答
  •  时光取名叫无心
    2021-02-13 13:36

    You are not setting the working directory path, and unlike when starting the application through Explorer, it isn't set automatically to the location of the executable.

    Just do something like this:

    processInfo.WorkingDirectory = Path.GetDirectoryName(pathToMyExe);
    

    (assuming the input files, DLLs etc. are in that directory)

提交回复
热议问题