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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Check file parameter

Check file parameter

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.
  • R Offline
    R Offline
    Ronni Marker
    wrote on last edited by
    #1

    Hi, Is there any who know how i can check it a user have pit an parameter behind the application name? ie. myapp.exe parameter I want to load a text file into a text field, and would like to know if it was possible to find out if the file could be loaded with a parameter like myapp.exe "C:\mytext.text" if im not not wrong this is also the way file extentions are loaded when you register an extention to your application. Marker

    S J 2 Replies Last reply
    0
    • R Ronni Marker

      Hi, Is there any who know how i can check it a user have pit an parameter behind the application name? ie. myapp.exe parameter I want to load a text file into a text field, and would like to know if it was possible to find out if the file could be loaded with a parameter like myapp.exe "C:\mytext.text" if im not not wrong this is also the way file extentions are loaded when you register an extention to your application. Marker

      S Offline
      S Offline
      Steve Hansen
      wrote on last edited by
      #2

      Use the property Environment.CommandLine to see the full commandline (including the program itself). Or use the method Environment.GetCommandLineArgs() string cmd = Environment.CommandLine; string[] cmds = Environment.GetCommandLineArgs(); You can check for if (cmds.Length == 2) cmds[0] will be the path of your app, and cmds[1] (if it exists) will be the first parameter after it

      R 1 Reply Last reply
      0
      • R Ronni Marker

        Hi, Is there any who know how i can check it a user have pit an parameter behind the application name? ie. myapp.exe parameter I want to load a text file into a text field, and would like to know if it was possible to find out if the file could be loaded with a parameter like myapp.exe "C:\mytext.text" if im not not wrong this is also the way file extentions are loaded when you register an extention to your application. Marker

        J Offline
        J Offline
        Judah Gabriel Himango
        wrote on last edited by
        #3

        If you're asking how to know if your app has been started with command lines, yes. In your static void Main(string[] args) function, args will contain any parameters passed to your app.

        Tech, life, family, faith: Give me a visit. I'm currently blogging about: Connor's Christmas Spectacular! Judah Himango

        1 Reply Last reply
        0
        • S Steve Hansen

          Use the property Environment.CommandLine to see the full commandline (including the program itself). Or use the method Environment.GetCommandLineArgs() string cmd = Environment.CommandLine; string[] cmds = Environment.GetCommandLineArgs(); You can check for if (cmds.Length == 2) cmds[0] will be the path of your app, and cmds[1] (if it exists) will be the first parameter after it

          R Offline
          R Offline
          Ronni Marker
          wrote on last edited by
          #4

          great thanks! This was just what i needed. Cheers.

          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