So a recent item that I've been tasked with is programmatically finding the application that is required to open/load a file of a given file extension. One would think that this would be a straightforward task and quite easy to accomplish with .Net.
My first thought was to check the System.Environment namespace for any mappings of file extensions. Nada. My next instinct was to check System.Runtime.InteropServices to see if there was a chance that some object (maybe Marshal) had access to such a table. No go. I also stopped by Microsoft.Win32...nothing as well.
I did come across an interesting method in System.Drawing.Icon, ExtractAssociatedIcon() which would be useful if that was what I was after. Unfortunately, I didn't find anything that would resemble this functionlity in System.IO.
So it would seem that for the time being, the only way that I can get at this data is to read registry keys.
What I've found is the following algorithm:
In some cases, it is enough to open the first key (the extension key) and you will find a subkey called OpenWithList with the first subkey being the name of the executable of the application (but this isn't always available).
I'm thinking there has to be a better way to do this programmatically, but I haven't come across it yet.
Remember Me
newtelligence dasBlog 1.8.5223.0
This site is a combo blog/portfolio for me, Charles Chen.
Sign In