-3

I am developing a windows application with c#. I need to get the file and folder name when I right click on a file to use for other functions. Right now I have made the registry keys to get my application running.

When I right click on a file (word, ppt, txt, etc) my context menu shows the option I added, Set Perm/ When that is selected my windows application opens up. In a text box on the form, I want to display the full file name and path of the file the user clicked on. Is there a way to do that?

I've added %0 and %1 in the registry to then end of the arguument to launch my app, but it does not work. I've tried h:\temp\myapp.exe %1 and h:\temp\myapp.exe %0. Putting the %1 or %0 in quotes did not change anything.

I am in Windows 8 using Visual Studio 2017. Searching brought me to this question, but it has not answered my problem yet.

Rufus L
  • 36,127
  • 5
  • 30
  • 43
trav1514
  • 1
  • 2

2 Answers2

0

if I understand what you're asking, to have the path passed in the register,

void Main(string[] args)

the Path class has some useful methods to get to the folder and the string of a string

 Path.GetFullPath("the path")

sometimes path is args[0](when you drag the file on icon), but in your case you have to iuse args[1].

I hope I understand what you're asking for

br1 Brown
  • 16
  • 1
0

Thanks for the help. The question referenced earlier did provide the answer. I was having issues with the form I was using. After working it with for a while I must have really messed it up. I created a new form and used it, using the code provided in that post i referenced.

trav1514
  • 1
  • 2