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

后端 未结 3 1503
刺人心
刺人心 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:33

    Due to different working directory, you have to set your working directory properly to the path that you want your process to start.

    A sample demonstration of this can be:

    Process process = new Process()
    {
        StartInfo = new ProcessStartInfo(path, "{Arguments If Needed}")
        {
            WindowStyle = ProcessWindowStyle.Normal,
            WorkingDirectory = Path.GetDirectoryName(path)
        }
    };
    
    process.Start();
    

提交回复
热议问题