7

I have written a word processor in C#. I would like to allow my program to open files when the user right clicks the file and selects "open with" and selects my program. How can I implement such a feature to my program? Currently, the only way the user can open a file is by using the OpenFileDialog.

As of now, if the user chooses to "Open with" and selects my program, it doesn't open up the file that they selected.

What is the best way to implement this feature?

tshepang
  • 12,111
  • 21
  • 91
  • 136
Toby
  • 377
  • 1
  • 10
  • 23
  • Checkout http://voidnish.wordpress.com/2004/05/10/a-simple-c-function-to-add-context-menu-items-in-explorer/ and http://forum.codecall.net/topic/68532-adding-my-program-to-contextmenu/ – Cyclonecode May 18 '13 at 21:38
  • Thanks... But I'm struggling to understand this. I'm new to programming. Could you possibly explain it to me, please? :) – Toby May 18 '13 at 21:55
  • You will need to add an entry for your application into the registry. The above links will show a couple of ways to do this. This http://stackoverflow.com/questions/3788429/c-sharp-windows-open-with-context-menu-behaviour also shows how you would process the commands sent to your application from the context menu. – Cyclonecode May 18 '13 at 22:00
  • Alright. I'll have a look into it. Thanks. – Toby May 18 '13 at 22:05

1 Answers1

4

"Open With" passes the file name as an argument to the application.

Take a look at the args parameter here.

Smurf64
  • 337
  • 1
  • 6
  • 15