Reputation: 4741
In C#, how do I refer the following locations rather than hard-coding them?
Upvotes: 6
Views: 2432
Reputation: 27509
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.
Upvotes: 13