怎样才能达到目标机的架构的程序文件的路径,无论 [英] How do get the path of Program Files regardless of the architecture of the target machine

查看:164
本文介绍了怎样才能达到目标机的架构的程序文件的路径,无论的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在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:\ 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屋!

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