views:

79

answers:

6

What would a 32 bit application running on Windows 7 return for the below -

Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles)?

C:\Program Files (x86) or C:\Program Files ??

+1  A: 

C:\Program Files (x86)

Jimmy Hoffa
+6  A: 

On 32 bit Windows 7 you should get "C:\Program Files", on 64 bit "C:\Program Files (x86)".

Mario
Can we by any means get the path C:\Program Files (x86) instead of C:\Program Files?
Sameer Rastogi
There's no need for the added "x86" on 32 bit systems. If you'd like to get the x86 path even while running a 64 bit app on a 64 bit system, request Environment.SpecialFolder.ProgramFilesX86 instead.
Mario
A: 

"C:\Program Files (x86)"

Philippe
A: 

This might be useful also (another SO question).

ck
+1  A: 

Well I'm running Windows 7 Ultimate 32 bit so I wanted to know for sure what was returned, so I put this into a console application to see what was returned

Console.WriteLine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles));

And it returned C:\Program Files

PsychoCoder
+3  A: 

It doesn't matter what it returns. Either value will map to the same folder, file system virtualization will always map it to (x86) for a 32-bit app.

Hans Passant
+1: Useful to know
ck