日期:2014-05-18  浏览次数:20928 次

Process.Start方法的问题
我要在应用程序A中启动应用程序B,同时传递一个参数给B。

我用Process.Start(yourApp, stringitem);这样可以在启动进程B的同时传递参数stringitem给B吗?

为何我在进程B里用ProcessStartInfo psi = new ProcessStartInfo();
  senderLocation = psi.Arguments;

无法得到A传递进来的参数?应该如何做?

------解决方案--------------------
Process.Start("youapplication", "agr0 arg1 arg2");
------解决方案--------------------
static void Main(string[] args)
{
string s1 = args[0];
string s2 = args[1];
}

------解决方案--------------------
Program.cs文件

[STAThread]
static void Main(string[] args)
{
forean(string arg in args)
 Debug.WriterLine(arg);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
if (runone())
Application.Run(new Form2());
}
------解决方案--------------------
在B中
public eform(string[] arg)
{
string[] a1 ;
for (int i = 0 .....)
{
a1[]i = arg[i];
}
}