Discovering open source WPF components – Orc.FileAssociation

In the discovering open source WPF components series, I will look into useful open source components that can be used to create WPF apps. This weeks component is Orc.FileAssociation.

Sometimes applications need to be associated with certain file types. When searching the internet for a solution, you mostly get some code that hacks the registry (and requires user elevation). This was the primary reason why Orc.FileAssociation was written: associate an application with file types without elevation and no need to hack the registry yourself. Depending on the version of Windows your end-users are using, below are the screenshots showing the process.

Example application

Windows 10 default apps

Windows 10 default apps

Application registration

First you need to register the application in the registry for applications to be able to be associated with file types. This can be done very easily by using the following code:

 

File association

To start the file association, use the following code:

 

Remember that this code does not require elevation and will associate file types for the current user.