Environment.SpecialFolder.ProgramFiles value for a 32-bit application on Windows 7?
Asked Answered
F

5

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?

Florenceflorencia answered 3/8, 2010 at 15:0 Comment(3)
This might be useful also (another SO question).Buntline
I think this assumes an English version of Windows.Microcyte
Do you want the path from a 32bit process file system view or a 64bit process (e.g. Windows Explorer)'s file system view?Grain
N
11

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

Nausea answered 3/8, 2010 at 15:3 Comment(3)
Can we by any means get the path C:\Program Files (x86) instead of C:\Program Files?Florenceflorencia
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.Nausea
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)Sheliasheline
H
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.

Hamon answered 3/8, 2010 at 15:26 Comment(0)
B
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

Bridgework answered 3/8, 2010 at 15:19 Comment(0)
C
1

C:\Program Files (x86)

Cratch answered 3/8, 2010 at 15:3 Comment(0)
M
0

"C:\Program Files (x86)"

Messmate answered 3/8, 2010 at 15:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.