简体   繁体   English

无法在C#中使用Process.Start()运行.exe程序

[英]Cannot run an .exe program by using Process.Start() in c#

I have a problem when I using Process.Start() to run an .exe file from Unity. 使用Process.Start()从Unity运行.exe文件时遇到问题。 I trying run other one with that code but it works. 我试图用该代码运行另一个,但它可以工作。 Here is my code: 这是我的代码:

if (GUI.Button (new Rect (20, 465, 150, 20), "Tháo / Lắp")) {
    Process.Start(Directory.GetCurrentDirectory() + "\\ThaoLapT64S\\module1.exe");
}

I put another .exe or .txt file to same folder but it works, and this file cannot run by the code above. 我将另一个.exe或.txt文件放到同一文件夹中,但它可以工作,并且该文件无法由上述代码运行。 I can run this file normally by double click on it. 我可以通过双击正常运行此文件。 I think it's a problem with this file. 我认为此文件有问题。 It is a graphic program. 这是一个图形程序。 Anyone can help me solve this problem. 任何人都可以帮助我解决这个问题。 Thanks so much! 非常感谢!

Try This 尝试这个

var processStartInfo = new ProcessStartInfo(Directory.GetCurrentDirectory() 
+ "\\ThaoLapT64S\\module1.exe");

processStartInfo.WorkingDirectory = Path.GetDirectoryName(Directory.GetCurrentDirectory() + "\\ThaoLapT64S\\module1.exe");

Process.Start(processStartInfo);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM