问题描述
我正在寻找一种以编程方式将文件夹添加到 Windows 资源管理器中的收藏夹的方法.它的 Windows Explorer 特定并基于此项目:http:///www.codeproject.com/Tips/132804/Open-folders-using-a-Run-Command
I am looking for a way to programmatically add a folder to the Favorites in Windows Explorer. Its Windows Explorer specific and based around this project: http://www.codeproject.com/Tips/132804/Open-folders-using-a-Run-Command
到目前为止,我已经尝试过 Process Monitor 并搜索注册表,但我似乎无法在 regedit
中找到我的 Windows Explorer 收藏夹.
So far I've tried Process Monitor and searching the registry, but I can't seem to find my Windows Explorer Favourites in regedit
.
<小时>Microsoft 在 Windows 8 中对此进行了更改,因此我相应地标记了我的问题.请参阅 Win8 & 的标记答案中的评论等细节.
Microsoft has changed this in Windows 8 so I have tagged my question accordingly. Please see the comments in the marked answer for Win8 & etc details.
推荐答案
PS:请务必查看 @bsegraves' 解决方案,我认为这是比我的好多了.
P.S.: Make sure to check out @bsegraves' solution, which I think is far better than mine.
我不确定这是否是您要查找的内容,但我认为可以通过以下注册表值找到最喜欢的文件夹:
I'm not sure if this is what you're looking for, but I think the favorite folder can be found through the following registry value:
HKEY_CURRENT_USER
Software
Microsoft
Windows
CurrentVersion
Explorer
User Shell Folders
Favorites
您应该能够使用以下代码检索此文件夹名称:
You should be able to retrieve this folder name with the following code:
using Microsoft.Win32;
...
RegistryKey topLevel = Registry.CurrentUser;
RegistryKey key = topLevel.OpenSubKey(
@"SoftwareMicrosoftWindowsCurrentVersionExplorerUser Shell Folders",
true);
string favoriteFolder = key.GetValue("Favorites").ToString();
然后只需在指定文件夹中创建链接或文档即可.
It's then only a matter of creating a link, or document, in the specified folder.
(请注意,此键的值可能类似于 %USERPROFILE%Favorites
;环境变量应由 .GetValue(..)
方法自动扩展上面调用过.)
(Take note that this key's value might be something like %USERPROFILE%Favorites
; the environment variable should automatically get expanded by the .GetValue(..)
method invoked above.)
这篇关于如何以编程方式将文件夹添加到用户的收藏夹(在 Windows 资源管理器中)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!