【问题标题】:How do I get a list of Windows Explorer Favorites shortcuts (*.lnk)?如何获取 Windows Explorer 收藏夹快捷方式 (*.lnk) 的列表?
【发布时间】:2018-04-04 18:21:46
【问题描述】:

我正在构建一个自定义的打开文件对话框,并希望显示与 Windows 资源管理器对话框的左窗格中相同的收藏夹列表。如何获取 Windows Explorer 收藏夹快捷方式 (*.lnk) 的列表?

【问题讨论】:

    标签: c# winforms list shortcut favorites


    【解决方案1】:

    Windows Explorer Favorites 快捷方式存储在 {SystemDrive}:\users{AccountName}\links 中。所以,这样的事情会在 C# 中完成

    string pathToLinks = Environment.GetEnvironmentVariable("USERPROFILE") + "\\Links";
    string[] fileEntries = Directory.GetFiles(pathToLinks, "*.lnk);
    

    【讨论】:

    • 使用Environment.GetFolderPath(Environment.SpecialFolder.Favorites) 而不是Environment.GetEnvironmentVariable("USERPROFILE") + "\\Links",因为用户可以修改他的收藏位置
    • Environment.GetFolderPath(Environment.SpecialFolder.Favorites) 返回 Internet Explorer 浏览器收藏夹的位置(不是显示在 Windows Explorer 对话框左窗格中的收藏夹列表)。我不确定 Windows Explorer 收藏夹 (%USERPROFILE%\Links) 的位置是否可以更改
    • 你不会做 Directory.GetFiles(pathToLinks, "*.lnk); 来过滤而不是在循环中过滤吗?
    • @NovaSysEng You can change the location 但有一个(相当复杂的)解决方案:stackoverflow.com/a/27987197/6730162
    • @TobiasBrohl 谢谢 - 我会看看,我会设计我的应用程序让用户浏览到他们选择的位置(使用“USERPROFILE”)+“\\Links”是默认(如果存在))并将其设置为我的应用的默认值
    猜你喜欢
    • 2012-05-07
    • 1970-01-01
    • 1970-01-01
    • 2010-09-23
    • 2010-09-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多