Windows 8/64位ProgramFiles环境变量 [英] Windows 8/64 bit ProgramFiles Environment Variables

查看:358
本文介绍了Windows 8/64位ProgramFiles环境变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我遇到的问题涉及ProgramFiles和ProgramFiles(x86).

我不知道这是我的计算机是Windows 8还是64位的问题,但是以下两种方法都可以解析为"C:\ Program Files(x86)":

Hi all,

The problem im having involves the ProgramFiles and ProgramFiles(x86).

I don''t know if this is just a problem with my machine being Windows 8 or it being 64bit but the following both resolve to "C:\Program Files (x86)":

string progfiles = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);
string progfilesx86 = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86);



使用其他来源,我可以看到其他人遇到了这个问题,但是有没有办法解决任何人都知道的问题?
谢谢!



Using other sources i can see other people have had this problem but is there any way around it that anyone knows?
Thanks!

推荐答案

,它取决于应用程序的目标平台..如果将其设置为x64构建,并在x64机器上运行,则应获取程序文件.另一方面,如果它是x86目标平台,那么即使您在x64机器上执行它,也可以获得C:\ Program Files(x86)
it depends on the Target platform of your app.. If you set it x64 build, and you run it on x64 machine you should get Program Files. On the other hand if it''s x86 target platform then you get C:\Program Files (x86) even if you execute it on x64 machine


可以通过编程快速解决此问题:

There is a quick fix to this programmatically:

string progfiles = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);
if (progfiles.EndsWith("(x86)"))
{
    progfiles = progfiles.Replace(" (x86)", "");
}
string progfilesx86 = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86);


这篇关于Windows 8/64位ProgramFiles环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆