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. How to get commandline parameter from User

How to get commandline parameter from User

Scheduled Pinned Locked Moved C#
tutorialquestion
4 Posts 4 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.
  • L Offline
    L Offline
    Laji59
    wrote on last edited by
    #1

    I want to get a parameter(for example "Path of Data") from user in commandline. How can I do it?

    Hello Friends

    V B P 3 Replies Last reply
    0
    • L Laji59

      I want to get a parameter(for example "Path of Data") from user in commandline. How can I do it?

      Hello Friends

      V Offline
      V Offline
      Vikram A Punathambekar
      wrote on last edited by
      #2

      Your Main method accepts a string array as a parameter. This contains what the user (or a shortcut) passed from the command line.

      Cheers, Vıkram.


      "if abusing me makes you a credible then i better give u the chance which didnt get in real" - Adnan Siddiqi.

      1 Reply Last reply
      0
      • L Laji59

        I want to get a parameter(for example "Path of Data") from user in commandline. How can I do it?

        Hello Friends

        B Offline
        B Offline
        Brij
        wrote on last edited by
        #3

        Please find below: public static void Main (string[] args) { if (args.Length > 0) { System.Console.WriteLine (args[0]); try { long number = long.Parse (args[0]); System.Console.WriteLine ("Number = " + number); } catch (System.FormatException e) { System.Console.WriteLine ("FormatException" + e); } return; } System.Console.WriteLine ("Please enter a number"); }

        Cheers!! Brij

        1 Reply Last reply
        0
        • L Laji59

          I want to get a parameter(for example "Path of Data") from user in commandline. How can I do it?

          Hello Friends

          P Offline
          P Offline
          Pete OHanlon
          wrote on last edited by
          #4

          There's this cunning command called GetCommandLineArgs in the Environment class. This should help.

          Deja View - the feeling that you've seen this post before.

          My blog | My articles

          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