In C#, show to refer the locations:
- Program Files (x86)
- Program Files
rather than hard-coding C:\Program Files (x86)
and C:\Program Files
In C#, show to refer the locations:
rather than hard-coding C:\Program Files (x86)
and C:\Program Files
You can use:
Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);
to get the program files folder on the machine. This will return what ever is correct for the app that is running. So for 32 bit apps on a 64 bit machine it will return "program files (x86)"
These two C# lines will get the required directories:
string f32 = Environment.GetEnvironmentVariable("ProgramFiles");
string f64 = Environment.GetEnvironmentVariable("ProgramW6432");
Typical values are
C:\Program Files (x86)
and
C:\Program Files
for f32 and f64 respectively.