Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Passing command line arguments to the main method

Passing command line arguments to the main method

Scheduled Pinned Locked Moved C#
question
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kourvoisier
    wrote on last edited by
    #1

    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.

    L 1 Reply Last reply
    0
    • K kourvoisier

      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.

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2
      1. 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
      W 1 Reply Last reply
      0
      • L Lost User
        1. 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
        W Offline
        W Offline
        Wayne Phipps
        wrote on last edited by
        #3

        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

        K 1 Reply Last reply
        0
        • W Wayne Phipps

          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

          K Offline
          K Offline
          kourvoisier
          wrote on last edited by
          #4

          Thanks!!! new it was something easy

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups