0

I pass some arguments from WPF app to WinForm apps like this.

int processID = Process.GetCurrentProcess().Id;

Process p = new Process();
p.StartInfo.FileName = FileManager.AppDirectoryName + "\\" + winformApp;
p.StartInfo.Arguments = string.Format("Param1={0}", processID );
p.Start();

But in other application I cannot see any args.

[STAThread]
static void Main()
{
 // Get start arguments 
 var process = Process.GetCurrentProcess();
 var args = process.StartInfo.Arguments; // It is empty. Why is it??

Any clue?

NoWar
  • 36,338
  • 80
  • 323
  • 498

1 Answers1

4
Process.GetCurrentProcess()

Returns

A new Process component associated with the process resource that is running the calling application.

This new component will have an empty startinfo member. Just use

Environment.GetCommandLineArgs()

Instead.

Hatted Rooster
  • 35,759
  • 6
  • 62
  • 122