I have added my application to the right click menu of Windows with the help of the registry
"C://myapp.exe "%1"
I am able to get the path of the selected file in a MessageBox
using the below code.
static void Main(string[] args)
{
foreach (string path in args)
{
MessageBox.Show(path);
}
}
It is okay if I want to open a single file, but if I select multiple files, it runs multiple instances of my application. I need the path of all selected file in the single instance only. Can anyone give me an idea of how to do this?
A non-programming work-around, to copy all the paths simultaneously is the following (tested at Windows 7):
All paths are copied as expected!
I tried it and the application is running a new instance for each selected file. I even tried to add "%2" "%3" etc to the registry command, that also did not work.
If it is really necessary to run a single instance for all files, maybe you can setup your app as with a class derived from WindowsFormsApplicationBase, set the IsSingleInstance property and override OnStartupNextInstance (no link to that 'cause my reputation does not allow more than 2 links)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With