get the parameters that came with running the progam

  • Thread starter Thread starter Rene
  • Start date Start date
R

Rene

Hi,


I want to start my (not console) application with HelloWorld.exe /test
How can i get/read the /test in my application ?

Greetings,
Rene
 
Hi,

I want to start my (not console) application with HelloWorld.exe /test
How can i get/read the /test in my application ?

Greetings,
Rene

args is NOT good enough for you? As in static void Main(string[]
args)...
 
I want to start my (not console) application with HelloWorld.exe /test
How can i get/read the /test in my application ?

So it's, what, a WinForms app? You might just be able to modify Program.cs
and add string[] args to Main(). Since Program is a static class, you'd just
need to expose this array as a property and then you can reference it from
your form.
 
args is NOT good enough for you? As in static void Main(string[] args)...

Well, he said it wasn't a console app (and failed to tell us what it WAS).
WinForms apps don't have the args argument in Program.cs, at least not the
default Program.cs generated by Visual Studio.
 
Rene said:
Hi,


I want to start my (not console) application with HelloWorld.exe /test
How can i get/read the /test in my application ?

Greetings,
Rene


string[] args = System.Environment.GetCommandLineArgs();

args now holds the name of the command currently executing as the first
element of the args array, and each parameter as an additional element in
the array.

HTH,
Mythran
 
string[] args = System.Environment.GetCommandLineArgs();

args now holds the name of the command currently executing as the first
element of the args array

Do you know offhand if it's the entire path or just the file name? If not,
I'll just test...one of these days.
 
Jeff said:
GArlington said:
I want to start my (not console) application with HelloWorld.exe /test
How can i get/read the /test in my application ?
args is NOT good enough for you? As in static void Main(string[] args)...

Well, he said it wasn't a console app (and failed to tell us what it WAS).
WinForms apps don't have the args argument in Program.cs, at least not the
default Program.cs generated by Visual Studio.

It should be possible to add it.

Arne
 
Rene schreef:
Hi,


I want to start my (not console) application with HelloWorld.exe /test
How can i get/read the /test in my application ?

Greetings,
Rene



Everyone thank u
Yes it is a form application

string[] args = System.Environment.GetCommandLineArgs();

did the trick

Greetings Rene
 
Back
Top