Iam尝试使用C#运行带有来自Unity的参数的.exe文件,这是我到目前为止所提出的;
System.Diagnostics.Process process = new System.Diagnostics.Process();
process.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal;
process.StartInfo.FileName = "C://PATH//ABC.exe";
process.StartInfo.Arguments = "ARGUMENT";
process.Start();
process.WaitForExit();
参数应该创建一个文本文件,但什么也没发生。
这个错误不断出现:
NullReferenceException: Object reference not set to an instance of an object
System.Diagnostics.Process.Start_common (System.Diagnostics.ProcessStartInfo startInfo,
System.Diagnostics.Process process) System.Diagnostics.Process.Start ()
(wrapper remoting-invoke-with-check) System.Diagnostics.Process:Start ()
任何人都可以告诉我为什么文本文件没有创建,我该如何修复此错误?
答案 0 :(得分:0)
在设置值之前尝试添加开始信息:
System.Diagnostics.Process process = new System.Diagnostics.Process();
process.StartInfo = System.Diagnostics.ProcessStartInfo();
process.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal;
process.StartInfo.FileName = "C://PATH//ABC.exe";
process.StartInfo.Arguments = "ARGUMENT";
process.Start();
process.WaitForExit();
像这样:
!!
希望有帮助