how to search if a file is present in the computer in c sharp?i need to find out if pdf reader is installed or not in a pc...please help..thank you

I'd check the registry rather than try to search the 100,000's of files on someones computer. On my machine, the key is Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Adobe\Acrobat Reader (this is W7 Ultimate 64bit). You'll probably have to find OS versions to figure out where it is for them.

Registry Class

Try to use this code:

using System;
using Microsoft.Win32;

namespace MyApp
{
    class Program
    {
        static void Main(string[] args)
        {
            RegistryKey adobe = Registry.LocalMachine.OpenSubKey("Software").OpenSubKey("Adobe");
            if (adobe != null)
            {
                RegistryKey acroRead = adobe.OpenSubKey("Acrobat Reader");
                if (acroRead != null)
                {
                    string[] acroReadVersions = acroRead.GetSubKeyNames();
                    Console.WriteLine("The following version(s) of Acrobat Reader are installed: ");
                    foreach (string versionNumber in acroReadVersions)
                    {
                        Console.WriteLine(versionNumber);
                    }
                }
            }
        }
    }
}

For searching any PDF reader, I would rather check for extensions in registers. Here you would get also which application takes care of pdf files. By default Windows doesn't know this extension, so this can help to check whether there is or not any PDF reader.
For example check here:
HKEY_CLASSES_ROOT\.pdf\OpenWithList

(Windows 7/8 can have built-in PDF reader, have not checked it )

Edited 5 Years Ago by Seten: Win7 remark was added.

This question has already been answered. Start a new discussion instead.