Reputation:
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?
Upvotes: 1
Views: 494
Reputation: 21125
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.
Upvotes: 0
Reputation: 7163
You can use Environment.GetCommandLineArgs() to get an array of the arguments passed into your program.
Upvotes: 3