Refer to 'Program Files' on a 64-bit machine
-
12-09-2019 - |
Question
In C#, how do I refer the following locations rather than hard-coding them?
- Program Files (x86)
- Program Files
Solution
You can use:
System.Environment.GetFolderPath(System.Environment.SpecialFolder.ProgramFiles);
to get the program files folder on the machine. This will return whatever is correct for the application that is running. So for 32-bit applications on a 64-bit machine, it will return "C:\Program Files (x86)" on a English version of Windows.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow