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. FileName as CommandLineArgument

FileName as CommandLineArgument

Scheduled Pinned Locked Moved C#
tutorialquestion
5 Posts 2 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.
  • G Offline
    G Offline
    GunaChinna
    wrote on last edited by
    #1

    How to pass a file name as command line argument in main function?

    C 1 Reply Last reply
    0
    • G GunaChinna

      How to pass a file name as command line argument in main function?

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      If you run your program from the console and type in the filename as in myprog.exe myfile.xt it will be passed in

      Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

      G 1 Reply Last reply
      0
      • C Christian Graus

        If you run your program from the console and type in the filename as in myprog.exe myfile.xt it will be passed in

        Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

        G Offline
        G Offline
        GunaChinna
        wrote on last edited by
        #3

        i am NOT running it from console. i have to run it in windows mode. A sample code would help me better.Could u please?

        C 1 Reply Last reply
        0
        • G GunaChinna

          i am NOT running it from console. i have to run it in windows mode. A sample code would help me better.Could u please?

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          There is no code to pass the filename, it has to be passed as a parameter. I think it's the same for windows apps. The string collection passed into your static void main contains the arguments. To pass it in, it needs to be an argument when the program is run. Or do you mean something else ?

          Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

          G 1 Reply Last reply
          0
          • C Christian Graus

            There is no code to pass the filename, it has to be passed as a parameter. I think it's the same for windows apps. The string collection passed into your static void main contains the arguments. To pass it in, it needs to be an argument when the program is run. Or do you mean something else ?

            Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

            G Offline
            G Offline
            GunaChinna
            wrote on last edited by
            #5

            i am trying and hope i will get it soon. And will get back to u if i need...

            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