How to pass multiple folders into my C# application's command line?


I have an application that processes a folder's contents by the user going into Windows Explorer and right-clicking on a folder, and choosing to "Convert images for iPhone".

The "Convert images for iPhone" popup menu verb was added to my environment by using the shown registry data to my registry.

My C# Windows Forms application processes figures out which folder to process by inspecting the results of "Environment.GetCommandLineArgs()".

Currently, if I select multiple folders and choose my verb in Windows Explorer, it just opens up a new instance of my application for each folder. So, selecting 3 folders runs 3 instances of my application at the same time.

What I would like to do now, is be able to select multiple folders within Windows Explorer, and process that list of folders within a SINGLE instance of my application.

How can I achieve this?

Perhaps I can pass them all in a single command-line, as %1 %2 %3, etc. If so, how do I set this up?

Or, is there some way to tell Windows to only run one instance of my application, and pass the folder names in a way other than the command-line arguments? How would I do this?

Windows Registry Editor Version 5.00
@="Convert images for iPhone"
@="\"C:\\dev\\mainline\\vs\\AutoRotatePhotos\\AutoRotatePhotos\\bin\\Debug\\AutoRotatePhotos.exe\" \"%1\""

Open in new window

Who is Participating?
Göran AnderssonConnect With a Mentor Commented:
You can use %* in the command to get all dropped filed instead of only the first. Try if that will make explorer send all the folders to the same instance.
@="\"C:\\dev\\mainline\\vs\\AutoRotatePhotos\\AutoRotatePhotos\\bin\\Debug\\AutoRotatePhotos.exe\" \"%*\""

Open in new window

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.