Command Line Arguments

  • Thread starter Thread starter Brian Scott
  • Start date Start date
B

Brian Scott

Is it possible to get the full command line argument string that was used to
launch your current process other than using the args[]. I would like to see
the original string before the args are interpreted.

Thanks.
 
Cheers, that helped.

James Curran said:
the Environment.CommandLine property.

Brian Scott said:
Is it possible to get the full command line argument string that was
used
to
launch your current process other than using the args[]. I would like to see
the original string before the args are interpreted.

Thanks.
 
Frisco,

That is what i was using prior but using the Environment variable seems
better as we can also see the execution path. I was trying to debug invalid
user enterred arguments.

Thanks
 
You cant however rely on that the execution path is in that string.

The user might have changed directory prior to start your application:
cd c:\dev
YourApp "An Argument"
or he might not:
c:\dev\YourApp.exe "An Argument"

but you are probably aware of that already.
 
If you want the path to your application at runtime, you can do:
string fullPath =
System.Reflection.Assembly.GetExecutingAssembly().Location;
 
Back
Top