Also, the docs for the .NET 3.5 version of the SpecialFolder enumeration
don't have the ProgramFilesX86 entry. I guess they added it in .NET 4.0.

Out of interest, what happens if you do this:

Environment.GetFolderPath((System.Environment.SpecialFolder)42)

Where 42 is the value assigned to ProgramFilesX86. I'm just wondering if
the value is important or if it goes to a giant switch
statement.<http://codermike.com>


On Wed, Feb 8, 2012 at 4:46 PM, Michael Minutillo <
michael.minuti...@gmail.com> wrote:

> Hi Ian,
>
> If all you want to do is start a process in code you can use the
> Environment.ExpandEnvironmentVariables(..) method to do it for you:
>
> Environment.ExpandEnvironmentVariables("%ProgramFiles(x86)%\\TextPad
> 5\\TextPad.exe")
>
> Returns
>
> C:\Program Files (x86)\TextPad 5\TextPad.exe
>
> on my machine. If you reference an environment variable that doesn't
> exist then it just doesn't get expanded.
>
> Regards,
>
> Michael M. Minutillo
> Indiscriminate Information Sponge
> http://codermike.com
>
>
>
> On Wed, Feb 8, 2012 at 4:36 PM, Ian Thomas <il.tho...@iinet.net.au> wrote:
>
>> ** ** **
>>
>> 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