C#调用外部EXE程序

 // 源程序                                            
using System;                                            
using System.Collections.Generic;                                            
using System.Text;                                            
using System.Diagnostics;                                            
                                            
namespace ConsoleApplication1                                            
{                                            
    class Program                                            
    {                                            
        static void Main(string[] args)                                            
        {                                            
            Process proc = new Process();                                            
            proc.StartInfo.FileName = @"C:\Users\r086145\Desktop\董小旺\CPK\Get_SpcTmr_BkData\ConsoleApplication2\bin\Debug\ConsoleApplication2.exe";                                            
            proc.StartInfo.Arguments = "abc bcd";                                            
            proc.Start();                        //传到应用程序的参数                    
        }                                            
    }                                            
}                                            
                                            
//需要调用的EXE程序                                            
namespace ConsoleApplication2                                            
{                                            
    class Program                                            
    {                                            
        static void Main(string[] args)                        //接收用户录入的参数   以空格隔开                    
        {                                            
            for (int i = 0; i < args.Length; i++)                                            
            {                                            
                Console.WriteLine(args[i].ToString());                                            
            }                                            
            Console.WriteLine("程序执行完毕");                                            
            Console.Read();                                            
        }                                            
    }                                            
}

 

posted @ 2018-04-28 15:49  Peaceful_Pig  阅读(677)  评论(0编辑  收藏  举报