Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/295.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C#和windows资源管理器的上下文菜单_C#_Wpf_Regedit - Fatal编程技术网

C#和windows资源管理器的上下文菜单

C#和windows资源管理器的上下文菜单,c#,wpf,regedit,C#,Wpf,Regedit,我试图将一个项目添加到Windows资源管理器()的上下文菜单中,结果成功了,但我仍然不知道如何获取所选文件的路径 我尝试了Environment.GetCommandLineArgs(),但它只返回应用程序的路径,而不返回所选文件 有人能告诉我怎么做吗?您需要设置命令以传递相关路径。而不是使用: // From the related article regcmd.SetValue("",this.txtPath.Text); 您应该能够使用: string command = stri

我试图将一个项目添加到Windows资源管理器()的上下文菜单中,结果成功了,但我仍然不知道如何获取所选文件的路径

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


有人能告诉我怎么做吗?

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

// 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