Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/365.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 通过C传递多个参数到C++ .exe文件 我有C++程序编译生成的EXE文件 现在我想通过C将参数传递给生成的exe文件,并将exe文件的所有输出保存到.txt文件中 这就是我到目前为止所做的 public static string RunCmd(params int[] commands) { string returnvalue = string.Empty; ProcessStartInfo info = new ProcessStartInfo("C:\\...\\.exe"); info.UseShellExecute = false; info.RedirectStandardInput = true; info.RedirectStandardOutput = true; info.CreateNoWindow = true; using (Process process = Process.Start(info)) { StreamWriter sw = process.StandardInput; StreamReader sr = process.StandardOutput; //foreach (int command in commands) //{ // sw.WriteLine(command); //} for (int i = 0; i < commands.Length; i++) { sw.WriteLine(commands[i]); } sw.Close(); returnvalue = sr.ReadToEnd(); process.Close(); System.IO.StreamWriter file = new System.IO.StreamWriter("C:\\..\\.txt"); file.WriteLine(returnvalue); file.Close(); return returnvalue; }_C# - Fatal编程技术网

C# 通过C传递多个参数到C++ .exe文件 我有C++程序编译生成的EXE文件 现在我想通过C将参数传递给生成的exe文件,并将exe文件的所有输出保存到.txt文件中 这就是我到目前为止所做的 public static string RunCmd(params int[] commands) { string returnvalue = string.Empty; ProcessStartInfo info = new ProcessStartInfo("C:\\...\\.exe"); info.UseShellExecute = false; info.RedirectStandardInput = true; info.RedirectStandardOutput = true; info.CreateNoWindow = true; using (Process process = Process.Start(info)) { StreamWriter sw = process.StandardInput; StreamReader sr = process.StandardOutput; //foreach (int command in commands) //{ // sw.WriteLine(command); //} for (int i = 0; i < commands.Length; i++) { sw.WriteLine(commands[i]); } sw.Close(); returnvalue = sr.ReadToEnd(); process.Close(); System.IO.StreamWriter file = new System.IO.StreamWriter("C:\\..\\.txt"); file.WriteLine(returnvalue); file.Close(); return returnvalue; }

C# 通过C传递多个参数到C++ .exe文件 我有C++程序编译生成的EXE文件 现在我想通过C将参数传递给生成的exe文件,并将exe文件的所有输出保存到.txt文件中 这就是我到目前为止所做的 public static string RunCmd(params int[] commands) { string returnvalue = string.Empty; ProcessStartInfo info = new ProcessStartInfo("C:\\...\\.exe"); info.UseShellExecute = false; info.RedirectStandardInput = true; info.RedirectStandardOutput = true; info.CreateNoWindow = true; using (Process process = Process.Start(info)) { StreamWriter sw = process.StandardInput; StreamReader sr = process.StandardOutput; //foreach (int command in commands) //{ // sw.WriteLine(command); //} for (int i = 0; i < commands.Length; i++) { sw.WriteLine(commands[i]); } sw.Close(); returnvalue = sr.ReadToEnd(); process.Close(); System.IO.StreamWriter file = new System.IO.StreamWriter("C:\\..\\.txt"); file.WriteLine(returnvalue); file.Close(); return returnvalue; },c#,C#,它适用于单个参数 但是,每当我试图输入多个参数时,它只打开.exe文件,而不进一步工作,可能的dUp,我不这么认为,exe文件是通过编译一个C++程序生成的,该程序使用两个数字作为输入注释,您的示例不传递像M.exe ARG1 ARG2 ARG3之类的参数,而是一些输入值。请澄清你到底在找什么。此外,确保链接有关的控制台重定向的问题/文章,你得到了这个代码。实际上,这个代码是为一个程序,只需要一个数字作为一个输入在其C++程序,但每当我尝试在其他程序,以两个数字作为输入。它不工作,并打开那个程序

它适用于单个参数
但是,每当我试图输入多个参数时,它只打开.exe文件,而不进一步工作,

可能的dUp,我不这么认为,exe文件是通过编译一个C++程序生成的,该程序使用两个数字作为输入注释,您的示例不传递像M.exe ARG1 ARG2 ARG3之类的参数,而是一些输入值。请澄清你到底在找什么。此外,确保链接有关的控制台重定向的问题/文章,你得到了这个代码。实际上,这个代码是为一个程序,只需要一个数字作为一个输入在其C++程序,但每当我尝试在其他程序,以两个数字作为输入。它不工作,并打开那个程序。函数调用时传递的代码,如RunCmd1,2;