Is there a way for a Windows Forms application to detect if any flags have been added to the command/shortcut used to launch it? Like if I wanted to go "app.exe /flag", can I get the "/flag" somewhere programatically?
+3
A:
You can use Environment.GetCommandLineArgs() to get an array of the arguments passed into your program.
Dan Walker
2009-07-01 18:36:04
I knew it'd be something stupidly obvious. Thanks!
2009-07-01 18:49:07
A:
Another approach is to handle the Application Startup
event where you'll have access to the StartupEventArgs
which has a property called CommandLine
which is a read-only collection of the command-line arguments.
Rob Sobers
2009-10-12 17:25:07