How can I programmatically check file that a file association exists before attempting to Process.Start() it? How can I programmatically check file that a file association exists before attempting to Process.Start() it? windows windows

How can I programmatically check file that a file association exists before attempting to Process.Start() it?


It's better not use the registry directly but rely on the Windows API instead. Here is a link on SO that gives a .NET solution: How do I get File Type Information based on extension? (not MIME) in c#


I found there is a .pdf key in the registry, maybe it can help you:

Windows Registry Editor Version 5.00[HKEY_CLASSES_ROOT\.pdf]"Content Type"="application/pdf"@="AcroExch.Document"[HKEY_CLASSES_ROOT\.pdf\OpenWithList]@=""[HKEY_CLASSES_ROOT\.pdf\OpenWithList\AcroRd32.exe]@=""[HKEY_CLASSES_ROOT\.pdf\ShellEx][HKEY_CLASSES_ROOT\.pdf\ShellEx\{8895b1c6-b41f-4c1c-a562-0d564250836f}]@="{DC6EFB56-9CFA-464D-8880-44885D7DC193}"