Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7579831
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T17:46:04+00:00 2026-05-30T17:46:04+00:00

It is sometimes desirable to have your application open the default application for a

  • 0

It is sometimes desirable to have your application open the default application for a file. For example, to open a PDF file you might use:

System.Diagnostics.Process.Start("Filename.pdf");

To open an image, you’d just use the same code with a different filename:

System.Diagnostics.Process.Start("Filename.gif");

Some extensions (.gif for example) just about always have a default handler, even in a base Windows installation. However, some extensions (.pdf for example) often don’t have an application installed to handle them.

In these cases, it’d be desirable to determine if an application is associated with the extension of the file you wish to open before you make the call to Process.Start(fileName).

I’m wondering how you might best implement something like this:

static bool ApplicationAssociated(string extension)
{
    var extensionHasAssociatedApplication = false;

    var condition = // Determine if there is an application installed that is associated with the provided file extension.;
    if (condition)
    {
        extensionHasAssociatedApplication = true;
    }

    return extensionHasAssociatedApplication;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T17:46:06+00:00Added an answer on May 30, 2026 at 5:46 pm

    I would recommend following the advice in David’s answer BUT since you need to detect an association:

    To check whether a file has an association you can use the native function FindExecutable which is basically what Windows Explorer uses internally… it gives a nice error code (SE_ERR_NOASSOC) if there is no association. Upon success it gives a path to the respective executable.

    Thee DllImport for it is

    [DllImport("shell32.dll")]
    static extern int FindExecutable(string lpFile, string lpDirectory, [Out] StringBuilder lpResult);
    

    Another option would be to walk the registry for example (not recommended since complex due to several aspets like WoW64 etc.):

    The real association is stored in the key that HKEY_CLASSES_ROOT\.pdf points to – in my case AcroExch.Document, so we checkoutHKEY_CLASSES_ROOT\AcroExch.Document. There you can see (and change) what command is going to be used to launch that type of file:

    HKEY_CLASSES_ROOT\AcroExch.Document\shell\open\command
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Sometimes pdf might have a transparent background. And In my application I have given
Sometimes I have to test some javascript code, that I use jsbin.com , but
Sometimes I have to work on code that moves the computer clock forward. In
Sometimes I get Oracle connection problems because I can't figure out which tnsnames.ora file
Sometimes I have a true colored image, by using dithering algorithm, I can reduce
Sometimes I have come across this issue that whenever I change the order of
We have an ASP.NET application that uses Forms Auth. When users log in, a
Sometimes it's very difficult to find an error in an application because of static
In our system we have accounts which contain items. An item is always associated
Sometimes I got a crash of my application with the following stack trace :

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.