类别:程序开发
日期:2020-04-15 浏览:2226 评论:0
System.Diagnostics.Process.Start("程序的路径", "参数1 参数2"); 第一个参数是aaa.exe 的路径,第二个参数是用空格分开的两个参数组成的字符串。 aaa.exe中的main方法写做 static void Main(string[] args) 用Process.Start启动aaa.exe时main方法的args参数就是Process.Start传入参数用转换成的长度为2的数组 代码如下 调exe的写法:
static void Main(string[] args) { System.Diagnostics.Process.Start(@"E:\SouceCode\WindowsFormsApplication1 - 副本\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.exe", "参数1 参数2"); }
被调的写法:
static void Main(string[] args) { if (args.Length > 0) { string canshu1 = args[0]; string canshu2 = args[1]; MessageBox.Show(canshu1); MessageBox.Show(canshu2); } Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); }
本文标题:C#中怎么用process调用一个exe文件并传入参数?
本文链接:https://vtzw.com/post/153.html
版权声明:本文不使用任何协议授权,您可以任何形式自由转载或使用。
发表评论 / 取消回复