“扩展环境变量”的问题 [英] Problem with "Expand Environment Variables"
问题描述
你好
我的路径有问题包含环境变量%% ProgramFiles %% ...
%% ProgramFiles %% \\test \\ filename.exe
我使用了Environment.ExpandEnvironmentVariables(Path)函数来转换它,结果是程序文件但结果应该是Program Files(x86),因为目标路径可以在Program Files(x86)文件夹中找到!!
我如何获得正确的文件夹?
抱歉我的英语不好!!
Hello
I have a problem with path wich contains Environment Variables "%%ProgramFiles%% ...
"%%ProgramFiles%%\\test\\filename.exe"
I used Environment.ExpandEnvironmentVariables(Path) function to convert it, the result was "Program Files" but the result should be "Program Files (x86)" because the target path is found in "Program Files (x86)" folder !!
How can i get the right folder ??
sorry for my poor english !!
推荐答案
请参阅有关StackOverflow的此答案 [ ^ ]
See this answer on StackOverflow[^]
看看这个答案: http://stackoverflow.com/questions/194157/c-sharp-how-to-get-program-files-x86-on -windows-vista-64-bit / 194223#194223 [ ^ ]
Have a look at this answer: http://stackoverflow.com/questions/194157/c-sharp-how-to-get-program-files-x86-on-windows-vista-64-bit/194223#194223[^]
以下函数将返回所有这三种Windows配置中的x86 Program Files目录:
32位Windows
在64位Windows上运行的32位程序
在64位Windows上运行的64位程序
The function below will return the x86 Program Files directory in all of these three Windows configurations:
32 bit Windows
32 bit program running on 64 bit Windows
64 bit program running on 64 bit windows
static string ProgramFilesx86()
{
if( 8 == IntPtr.Size
|| (!String.IsNullOrEmpty(Environment.GetEnvironmentVariable("PROCESSOR_ARCHITEW6432"))))
{
return Environment.GetEnvironmentVariable("ProgramFiles(x86)");
}
return Environment.GetEnvironmentVariable("ProgramFiles");
}
这篇关于“扩展环境变量”的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!