leosco

leosco

  • NA
  • 13
  • 0

Passing command-line arguments in another form

Nov 2 2010 10:58 AM

nevermind, problem has been solved.

Hi.
I have registered a file association with my program, and when the file is clicked I want it to open with my application by passing a command line argument. I have already done this and in Program.cs I have added:
static void Main(string[] args)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Main x = new Main();
x.Launch(args[0]);
Application.Run(x); // I also tried Application.Run(new Main());
}

Launch is a function in my main form, I want to pass the arguments there. From there, I want to change the text of the form (this.Text = args for example), but it doesn't work.

Can someone please help me pass the argument to the main form so I can use it there on my main form?

Answers (1)