Passing command line arguments to the main method
-
This just baffles me! I know it is something simple and right under my nose but cant figure it out static void Main(string[] args) { MessageBox.Show(args[0]); } How do i pass in arguments prior to running this program.
-
This just baffles me! I know it is something simple and right under my nose but cant figure it out static void Main(string[] args) { MessageBox.Show(args[0]); } How do i pass in arguments prior to running this program.
- Create a link, and add them to the textbox that points to your program C:\Programs\MyFile.exe -parameter1 -parameter2 2) Open the command prompt and do the same: > MyFile.exe -parameter1 ... 3) In Visual Studio: Menu: "Project -> [Program] properties..." Then on the left: "Debug" and in the middle: "Command line arguments" There are plenty of other possibilities, but these are the most common ones. regards
-
- Create a link, and add them to the textbox that points to your program C:\Programs\MyFile.exe -parameter1 -parameter2 2) Open the command prompt and do the same: > MyFile.exe -parameter1 ... 3) In Visual Studio: Menu: "Project -> [Program] properties..." Then on the left: "Debug" and in the middle: "Command line arguments" There are plenty of other possibilities, but these are the most common ones. regards
Alternatively, create a shortcut to your application and edit the shortcut by Right-clicking and selecting properties. On the 'Shortcut' tab, just add the arguments you want in the target box so:
Target: "C:\program files\my app\my app.exe"
would become:Target: "C:\program files\my app\my app.exe" myArgument1 myArgument2
This way you can setup different shortcuts that each pass different arguments. Hope this helps. Regards Wayne Phipps ____________ Time is the greatest teacher... unfortunately, it kills all of its students View my Blog -
Alternatively, create a shortcut to your application and edit the shortcut by Right-clicking and selecting properties. On the 'Shortcut' tab, just add the arguments you want in the target box so:
Target: "C:\program files\my app\my app.exe"
would become:Target: "C:\program files\my app\my app.exe" myArgument1 myArgument2
This way you can setup different shortcuts that each pass different arguments. Hope this helps. Regards Wayne Phipps ____________ Time is the greatest teacher... unfortunately, it kills all of its students View my BlogThanks!!! new it was something easy