Possible Duplicate:
C# – How to get Program Files (x86) on Vista x64
What is the best way to handle navigating whether a computer is 64 bit or not in C#?
Currently I do the following in C#:
bool is64bit = false;
Within the main method:
if (Directory.Exists("C:\\Program Files (x86)"))
{
is64bit = true;
}
Is there a better way to handle Program Files then that? As in later when I call a process that installs by default in Program Files, is there a shortcut I can use other then seeing if it exists?
Just use the
%ProgramFiles%Environment Variable.If running on a 64-bit system, depending on if you’re application is running in 32-bit or 64-bit mode, it will appropriately return either
C:\Program Files (x86)orC:\Program Files(assuming the user hasn’t changed the location).