I have only tried this in LINQPad/LINQPad4, but this statement when run:

var Filename = 
Environment.GetFolderPath(System.Environment.SpecialFolder.ProgramFilesX86);

produces the following error in LINQPad (Net 3.5):

'System.Environment.SpecialFolder' does not contain a definition for 
'ProgramFilesX86'

But is fine in LINQPad4 (Net 4.0), so it is only available in Net 4.0 and not 
3.5.

Note: you also have the case wrong in your code fragment as well - it should be 
ProgramFilesX86

Cheers
Chris

From: ozdotnet-boun...@ozdotnet.com [mailto:ozdotnet-boun...@ozdotnet.com] On 
Behalf Of Ian Thomas
Sent: Wednesday, 8 February 2012 7:36 PM
To: ozdotnet@ozdotnet.com
Subject: Environment variable ProgramFilesx86 - for x86 on 64-bit Windows

Is there an environment variable ProgramFilesx86 to locate C:\Program Files 
(x86) on a 64-bit Windows?
Although some of the MSDN documentation specifically mentions an environment 
variable ProgramFilesX96 member in the Environment.SpecialFolder Enumeration 
(http://msdn.microsoft.com/en-us/library/system.environment.specialfolder.aspx 
), it isn't shown by intellisense - 
Environment.GetFolderPath(System.Environment.SpecialFolder.ProgramFilesx86) and 
doesn't compile.
Further, while I can use the Windows Run to expand %ProgramFiles(x86)% -
"%ProgramFiles(x86)%\TextPad 5\TextPad.exe" -m -r  "C:\Users\(some 
location)\MyApp.log"
will work as desired, for example - if I want to start a process in code it 
doesn't expand the environment variable -
MyProcess.StartInfo.Filename = "%ProgramFiles(x86)%\TextPad 5\TextPad.exe"
(fails)
I am using 3.5 Framework, and need to remain with this. Maybe in 4.0 the doco 
is correct and this works (have not tried) - or am I missing a few very obvious 
things?
________________________________
Ian Thomas
Victoria Park, Western Australia

Reply via email to