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