1. via Environment variables
static string ProgramFilesx86()
{
if( 8 == IntPtr.Size
|| (!String.IsNullOrEmpty(Environment.GetEnvironmentVariable("PROCESSOR_ARCHITEW6432"))))
{
return Environment.GetEnvironmentVariable("ProgramFiles(x86)");
}
return Environment.GetEnvironmentVariable("ProgramFiles");
}
2. Environment.GetFolderPath
System.Environment.GetFolderPath(
System.Environment.SpecialFolder.ProgramFiles)
or
System.Environment.GetFolderPath(
System.Environment.SpecialFolder.ProgramFilesX86)
本文介绍了两种获取Program Files路径的方法:一是通过环境变量检查的方式确定路径;二是直接利用.NET Framework提供的API函数Environment.GetFolderPath来获取。
1526

被折叠的 条评论
为什么被折叠?



