Search code examples
c#winformslistshortcutfavorites

How do I get a list of Windows Explorer Favorites shortcuts (*.lnk)?


I'm building a custom open file dialog and want to display the same list of favorites that appears in the left pane of a Windows Explorer dialog. How do I get a list of Windows Explorer Favorites shortcuts (*.lnk)?


Solution

  • The Windows Explorer Favorites shortcuts are are stored in {SystemDrive}:\users{AccountName}\links. So, something like this will do it in C#

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