Possible Duplicate:
How to associate a file extension to the current executable in C#
So, I’m making an application for school (final project).
In this application, I have a Project-class.
This can be saved as a custom file, e.g. Test.gpr.
(.gpr is the extension).
How can I let windows/my application associate the .gpr file with this application, so that if I doubleclick the .gpr file, my application fires and opens the file
(so launches the OpenProject method – This loads the project).
I am NOT asking how to let windows associate a file type with an application, I am asking how to catch this in my code in Visual Studio 2012.
UPDATE:
Since my question seems to be not so clear:
atm, I’ve done nothing, so I can follow whatever is the best solution. All I want is to doubleclick the .gpr, make sure windows knows to open it with my app, and catch the filepath in my application.
Any help is greatly appreciated!
When you open a file with an application, the path to that file is passed as the first command line argument.
In C#, this is
args[0]of yourMainmethod.WPF
In case your project is an WPF application, in your
App.xamladd aStartupevent handler:Your command line arguments will now be in
e.Argsof theApplication_Startupevent handler: