获取“我的文档"在Windows Vista或7上 [英] Get "My Documents" on Windows Vista or 7

查看:82
本文介绍了获取“我的文档"在Windows Vista或7上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



当我在Windows XP上使用Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)或Environment.GetFolderPath(Environment.SpecialFolder.Personal)时,效果很好.

当我在Windows Vista上使用这些文件时,它将返回空白并将文件放在C:\ Windows \ System32文件夹中.

当我在Windows 7上使用它们时,它总是返回C:\ Users \ dean \ Documents.

问题是我已将我的文档"重定向到驱动器F:\.
有谁知道如何在Vista和7上获得我的文档"的真实(重定向)位置?感谢任何帮助!

Hi,

When I use Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) or Environment.GetFolderPath(Environment.SpecialFolder.Personal) on Windows XP it works great.

When I use these on Windows Vista it returns blank and puts files in my C:\Windows\System32 folder.

When I use these on Windows 7 it always returns C:\Users\dean\Documents.

The problem is I have redirected "My Documents" to drive F:\.
Does anyone know how to get the true (redirected) location of "My Documents" on Vista and 7? Any help appreciated!

推荐答案

您正在使用Environment.SpecialFolder.MyDocuments枚举. 重定向"是什么意思?

根据MSDN页面,它应该知道如何检索用户指定的文件夹.


您是否可以使用.Net 3.5而不是2.0进行尝试?
You''re after the Environment.SpecialFolder.MyDocuments enumeration. What do you mean by "redirected"?

According to the MSDN page, it should know how to retrieve folders that have been specified by the user.


Is it possible for you to try it using .Net 3.5 instead of 2.0?


我想我没有提供足够的信息(尽管当时我还不知道).我在安装程序中使用了这些方法. Windows Vista和7以管理员身份自动运行安装程序,这就是为什么我的MyDocuments和Personal位置不正确的原因. 感谢您的协助!
院长
I guess I did not give enough information (though I didn''t know that at the time). I was using these methods in my installer program. Windows Vista and 7 automatically run install programs as administrator which is why I got incorrect locations for MyDocuments and Personal.
Thanks for all assistance!
Dean


这篇关于获取“我的文档"在Windows Vista或7上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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