Nemo
Nemo

Reputation: 4741

Refer to 'Program Files' on a 64-bit machine

In C#, how do I refer the following locations rather than hard-coding them?

Upvotes: 6

Views: 2432

Answers (1)

Simon P Stevens
Simon P Stevens

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

Related Questions