c程序怎么执行?C#程序在某种情况下需要打开另外一个exe程序,下面介绍2种方式:,我来为大家科普一下关于c程序怎么执行?以下内容希望对你有帮助!
c程序怎么执行?C#程序在某种情况下需要打开另外一个exe程序,下面介绍2种方式:,我来为大家科普一下关于c程序怎么执行?以下内容希望对你有帮助!
c程序怎么执行
C#程序在某种情况下需要打开另外一个exe程序,下面介绍2种方式:
方法一
string[] the_args = { "1","2","3","4"};// 被调exe接受的参数// 被调exe接受的参数,将参数拼接成字符串 string the_args = "";foreach (string arg in args){the_args = the_argsarg" ";}the_args = the_args.Trim();string exe_path = pict1.AccessibleName;// 被调exe的路径System.Diagnostics.Process.Start(exe_path, the_args);
方法二
// 调用exe的函数using System.Diagnostics;public bool StartProcess(string exe_path, params string[] args) {string s = "";foreach (string arg in args){s = sarg" ";}s = s.Trim();Process process = new Process();//创建进程对象ProcessStartInfo startInfo = new ProcessStartInfo(runFilePath, s); // 括号里是(程序名,参数)process.StartInfo = startInfo;process.Start();return true; }string exe_path = "E:/CIS.exe";// 被调exestring[] the_args = { "1","2","3","4"};// 被调exe接受的参数StartProcess(exe_path, the_args);