Question

I tried to add an item to context menu of the Windows Explorer (http://www.codeproject.com/Articles/10104/Add-a-context-menu-to-the-Windows-Explorer), and it worked but I still don't know how to get the path of selected files?

I tried Environment.GetCommandLineArgs() but it only returns the path of my application and not the selected files.

Can anyone tell me how this can be done?

Was it helpful?

Solution

You need to set the command to pass the related path. Instead of using:

// From the related article
regcmd.SetValue("",this.txtPath.Text);  

You should be able to use:

string command = string.Format("\"{0}\" \"%1\"", this.txtPath.Text);
regcmd.SetValue("", command);  

This builds a command string that includes the path to your executable (this.txtPath.Text) followed by the selected item used when triggering the context menu (%1).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top