Click here to Skip to main content
15,887,917 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
How can I find program files (x86) folder in win 7 64 bit OS from .net 2008 ?
Posted

1 solution

Below provided function will return the x86 Program Files directory in all 3 of the windows configurations

32 bit Windows
32 bit program running on 64 bit Windows
64 bit program running on 64 bit windows

static string ProgramFilesx86()
{
    if( 8 == IntPtr.Size || (!String.IsNullOrEmpty(Environment.GetEnvironmentVariable("PROCESSOR_ARCHITEW6432"))))
    {
        return Environment.GetEnvironmentVariable("ProgramFiles(x86)");
    }

    return Environment.GetEnvironmentVariable("ProgramFiles");
}
 
Share this answer
 
Comments
mistryshailesh 2-Mar-12 2:36am    
Thanx a lot, it worked

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900