List contents in Favorites Folder

jbullard

New member
Joined
May 1, 2005
Messages
3
Programming Experience
5-10
All,

I am having a bit of a problem. What I would like to do is get all the favorite links inside a WinXP users favorites folder and then be able to display that in a combo box so they may click on a link and then hit the go button to go to that webpage. I have it setup now where all the url's are hard coded and it works fine. But I need to be able to automatically fill the combo box with each users favorites. Any help would be appreciated.

Here is the code for the button.
VB.NET:
	Public Explorer As SHDocVw.InternetExplorer

	Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
		'We need to make sure you select a web address
		If (cmbFavorites.SelectedItem = "") Then
			MsgBox("You must first select a web address.")
		Else
		 Explorer = New SHDocVw.InternetExplorer	 'Creates a new instance of IE
		 Explorer.Visible = True					 'Lets you see IE
		 Explorer.Navigate(cmbFavorites.SelectedItem) 'Navigates URL to desired web address
		End If
	End Sub

Thanks again for any help.

Jason
 

Lycaon

New member
Joined
Apr 20, 2005
Messages
3
Programming Experience
5-10
Favorites are stored as URL shortcuts in the user's Favorites folder. Easiest way to do what you're after would be something like the following. Excuse any goof ups if you copy/paste it, I didn't type it in the IDE so there might be missing parentheses and whatnot.

This works on XP. I'm not sure how it'd fare on pre-NT systems.

VB.NET:
Dim sFavoritesPath As String = Environment.GetFolderPath(Environment.SpecialFolder.Favorites)
Dim Files() As String = System.IO.Directory.GetFiles(sFavoritesPath)
Dim x As Integer, FileName As String 
 
For x = 0 To Files.Length - 1 ' Loop through all the files
FileName = Files(x).SubString(Files(x).LastIndexOf("\") + 1)
cmbFavorites.Items.Add FileName
Next

-------------------------------------------------------------------

The actual contents of the file look like this. You'll have to actually open each shortcut and extract the URL from it.

[DEFAULT]
BASEURL=http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwxp/html/WinXP_BITS.asp
[DOC#7#9#10#8#9]
BASEURL=http://msdn.microsoft.com/library/shared/searchtab/search.asp?stcfg=/library/searchtabconfig.xml&dtcfg=/library/deeptreeconfig.xml&url=/library/en-us/dnwxp/html/WinXP_BITS.asp?frame=true
ORIGURL=/library/shared/searchtab/search.asp?stcfg=/library/searchtabconfig.xml&dtcfg=/library/deeptreeconfig.xml&url=/library/en-us/dnwxp/html/WinXP_BITS.asp?frame=true
[DOC#7#9#11#6#8]
BASEURL=http://msdn.microsoft.com/library/en-us/dnwxp/html/xptheming.asp?frame=true
ORIGURL=/library/en-us/dnwxp/html/WinXP_BITS.asp?frame=true
[InternetShortcut]
URL=http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwxp/html/WinXP_BITS.asp
Modified=F06FDDCD0D2AC50106
 
Last edited:
Top Bottom