Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get args of Form program?

How can I get args of Form program? In console application I can use args[] but what about Form Application?

like image 638
Ichibann Avatar asked Jan 24 '11 08:01

Ichibann


2 Answers

One simple way:

string[] args = Environment.GetCommandLineArgs();

Alternatively you could change the Main-call to include parameters (in Program.cs):

static void Main(string[] args)
{

You will then need to pass it into your Form, and change your form's constructor accordingly (assuming that's where you need the args):

public Form1(string[] args)
{
like image 188
Tedd Hansen Avatar answered Oct 05 '22 10:10

Tedd Hansen


You need to change the form constructor to accept an args parameter.

eg:

public void Form1(string[] args)
{

}
like image 24
WraithNath Avatar answered Oct 05 '22 11:10

WraithNath