5

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?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Sameer Rastogi
  • 51
  • 1
  • 1
  • 2

5 Answers5

11

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

Mario
  • 35,726
  • 5
  • 62
  • 78
  • Can we by any means get the path C:\Program Files (x86) instead of C:\Program Files? – Sameer Rastogi Aug 05 '10 at 08:35
  • 1
    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 Aug 06 '10 at 17:37
  • 4
    That is not fully true - it depends on the bitness of the process ... `SpecialFolder.ProgramFiles` in an x86 build on an x64 os gives you *C:\Program Files (x86)* –  Nov 26 '15 at 15:22
8

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
  • 922,412
  • 146
  • 1,693
  • 2,536
3

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
  • 10,570
  • 12
  • 44
  • 60
1

C:\Program Files (x86)

Jimmy Hoffa
  • 5,909
  • 30
  • 53
0

"C:\Program Files (x86)"

Philippe
  • 3,945
  • 3
  • 38
  • 56