如何以编程方式检索实际路径"程序文件"夹? [英] How do I programmatically retrieve the actual path to the "Program Files" folder?

查看:196
本文介绍了如何以编程方式检索实际路径"程序文件"夹?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
  <一href="http://stackoverflow.com/questions/194157/c-sharp-how-to-get-program-files-x86-on-windows-vista-64-bit">C# - 如何让程序文件(x86)在Windows Vista 64位

我知道一个用户更改Windows默认的C的可能性:\ Program Files文件是相当渺茫,但奇怪的事情发生。

I realize the odds of a user changing the Windows default of C:\Program Files is fairly slim, but stranger things have happened!

如何才能得到正确的路径程序文件从系统?

How can I get the correct path to Program Files from the system?

推荐答案

.NET提供了的的特殊文件夹的程序文件,我的文档,等等。

.NET provides an enumeration of 'special folders' for Program Files, My Documents, etc.

在code从枚举转换成实际的路径是这样的:

The code to convert from the enumeration to the actual path looks like this:

Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles)

<一个href="http://msdn.microsoft.com/en-us/library/14tx8hby.aspx">http://msdn.microsoft.com/en-us/library/14tx8hby.aspx

这篇关于如何以编程方式检索实际路径&QUOT;程序文件&QUOT;夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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