3

我试图将一个项目添加到 Windows 资源管理器的上下文菜单(http://www.codeproject.com/Articles/10104/Add-a-context-menu-to-the-Windows-Explorer),它工作但我仍然不知道如何获取所选文件的路径?

我试过Environment.GetCommandLineArgs()了,但它只返回我的应用程序的路径,而不是选定的文件。

谁能告诉我如何做到这一点?

4

1 回答 1

1

您需要设置命令以传递相关路径。而不是使用:

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

您应该能够使用:

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

这将构建一个命令字符串,其中包含可执行文件 ( this.txtPath.Text) 的路径,后跟触发上下文菜单 ( %1) 时使用的选定项。

于 2014-01-07T19:26:57.740 回答