C# : capturing the file and path of a file when right I right click on the file

dodgerfan
dodgerfan used Ask the Experts™
on
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. Is there a way to do that? I've added %0 and %1 in the registry to the end of the argument 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. Thanks.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Commented:
Can you process selected file event?
In this case you can use method
Path.GetFullPath(path)

Open in new window

to get ful path.
Also you can use method
Path.GetFileNameWithoutExtension(path)

Open in new window

to get file name.

Author

Commented:
I was calling code to pull that name from the wrong event. Once I got it to the right event, it fires correctly and shows the file name and ful path. Thanks.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial