怎样才能达到目标机的架构的程序文件的路径,无论 [英] How do get the path of Program Files regardless of the architecture of the target machine
问题描述
我在C#/编程。NET。我希望能够从目标机器无论什么目标机器的架构是返回Program Files目录。为了澄清,我想它返回 C(或任何驱动OS上):/ Program Files文件
不管位数他们的Windows版本
I'm programming in C#/.NET. I want to be able to return the Program Files directory from the target machine no matter what the architecture of the target machine is. To clarify, I want it to return C (or whatever drive the OS is on):/Program Files
no matter what bitness their version of Windows is.
我只能硬code。在目录中,除非用户正在运行,这不是安装在C的Windows:驱动器将不能正常工作
I could just hardcode in the directory except if the user was running Windows that's not installed on the C: drive it wouldn't work.
我发现
FileInfo(System.Environment.GetFolderPath(System.Environment.SpecialFolder.ProgramFiles)
但我认为它返回程序文件(x86)
文件夹中的64位Windows计算机上。
but I think it returns the Program Files (x86)
folder on a 64 bit windows machine.
推荐答案
<$c$c>System.Environment.GetFolderPath(System.Environment.SpecialFolder.ProgramFiles)$c$c>返回C:\ Program Files文件
64位计算机上,除非code是建立目标86,在这种情况下,它返回C:\ Program Files文件(x86)的。
,所以我想这会为你工作。
System.Environment.GetFolderPath(System.Environment.SpecialFolder.ProgramFiles)
returns "c:\Program Files"
on a 64-bit machine, unless the code is build to target x86, in which case it returns "C:\Program Files (x86)"
, so I guess that would work for you.
这篇关于怎样才能达到目标机的架构的程序文件的路径,无论的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!