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. Environment.GetCommandLineArgs(); [modified]

Environment.GetCommandLineArgs(); [modified]

Scheduled Pinned Locked Moved C#
databasedata-structuresjsonhelpworkspace
2 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.
  • S Offline
    S Offline
    schiebel t
    wrote on last edited by
    #1

    hello, my problem: i like to select multible mp3 files in the windows explorer, open and process them with my application. I think it works with the GetCommandLineArgs() Methode (bsp. string[] args = Environment.GetCommandLineArgs()). This Method returns a string array. But when i select more than 1 mp3 file in the windows explorer, and show the Length of the args array, it alwas says 2. Index 0 is always the url of my programm. Index 1 is the url of the first selectet mp3 in the windows explorer, and the rest is emty. But why, i like to get each url of each mp3. I hope you understand me

    modified on Wednesday, October 22, 2008 3:08 AM

    D 1 Reply Last reply
    0
    • S schiebel t

      hello, my problem: i like to select multible mp3 files in the windows explorer, open and process them with my application. I think it works with the GetCommandLineArgs() Methode (bsp. string[] args = Environment.GetCommandLineArgs()). This Method returns a string array. But when i select more than 1 mp3 file in the windows explorer, and show the Length of the args array, it alwas says 2. Index 0 is always the url of my programm. Index 1 is the url of the first selectet mp3 in the windows explorer, and the rest is emty. But why, i like to get each url of each mp3. I hope you understand me

      modified on Wednesday, October 22, 2008 3:08 AM

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      That because Explorer only launches your application with one file at a time. Your code is expecting this:

      MyApp.exe file1.txt file2.txt file3.txt file4.txt

      Explorer is actually launching this:

      MyApp.exe file1.txt
      MyApp.exe file2.txt
      MyApp.exe file3.txt
      MyApp.exe file4.txt

      Google for "Single instance application c#" for examples on how to deal with this situation and pass the filename from one instance of your app to another.

      A guide to posting questions on CodeProject[^]
      Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
           2006, 2007, 2008

      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