How do I programmatically add a folder to the user's Favorites (in Windows Explorer)?

Jeremy Thompson picture Jeremy Thompson · Nov 24, 2010 · Viewed 9.9k times · Source

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

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 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.

Answer

bsegraves picture bsegraves · Sep 21, 2011

Instead of reading the registry, you can do the following:

string favoritesFolder = 
    Environment.GetFolderPath(Environment.SpecialFolder.Favorites);