在Windows开发,有时候需要调起另外一个可执行文件,正常来说会这么写:
Process proc = new Process();string MainAppPath = "test.exe";//the path of the exe fileproc.StartInfo.FileName = MainAppPath;proc.Start();
但是有时候调用不起来。其实我们还需要一句,来获取test.exe
的工作路径:
Process proc = new Process();string MainAppPath = "test.exe";//the path of the exe fileproc.StartInfo.FileName = MainAppPath;proc.StartInfo.WorkingDirectory = Path.GetDirectoryName(MainAppPath);;proc.Start();
这样就可以顺利调用了。