C# 使用unity c中的参数运行.exe文件#

C# 使用unity c中的参数运行.exe文件#,c#,unity3d,process,C#,Unity3d,Process,我想使用C#运行一个带有unity参数的.exe文件,我看过很多教程,也尝试了很多说明,这就是我到目前为止想到的: System.Diagnostics.Process进程=新的System.Diagnostics.Process(); System.Diagnostics.ProcessStartInfo startInfo=新系统.Diagnostics.ProcessStartInfo(); startInfo.WindowStyle=System.Diagnostics.ProcessW

我想使用C#运行一个带有unity参数的.exe文件,我看过很多教程,也尝试了很多说明,这就是我到目前为止想到的:

System.Diagnostics.Process进程=新的System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo startInfo=新系统.Diagnostics.ProcessStartInfo();
startInfo.WindowStyle=System.Diagnostics.ProcessWindowStyle.Normal;
startInfo.FileName=“C://PATH//ABC.exe”;
startInfo.Arguments=“ARGUMENT”;

参数应该创建一个文本文件,但是没有发生任何事情,并且没有错误。谁能告诉我为什么文本文件没有创建。

这不会启动进程。您需要设置流程的
StartInfo
,然后启动流程

// Create a process
System.Diagnostics.Process process = new System.Diagnostics.Process();

// Set the StartInfo of process
process.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal;
process.StartInfo.FileName = "C://PATH//ABC.exe";
process.StartInfo.Arguments = "ARGUMENT";

// Start the process
process.Start();
process.WaitForExit();

现在,当我尝试使用
NullReferenceException:Object reference未设置为对象System.Diagnostics.Process.Start\u common(System.Diagnostics.ProcessStartInfo-startInfo,System.Diagnostics.Process-Process)System.Diagnostics.Process()的实例时,出现了此错误System.Diagnostics.Process:Start()
尝试不使用
WaitForExit()