Click to See Complete Forum and Search --> : Favorites
NV2002
January 10th, 2003, 09:16 AM
Hi All,
How to you create a 'Favorite' entry in VB.net? I want to make
a Bookmark type app and would like to use the favorites already on the machine. What is in a favorite entry anyway. It must hold the URL and name etc..
Thanks,
Nick
DdH
January 11th, 2003, 10:44 AM
Try the following code.
Danny
Dim NameUrl As String = "CodeGuru"
Dim Url As String = "www.codeguru.com"
Dim key As Microsoft.Win32.RegistryKey
Dim value As String
key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\")
value = key.GetValue("Favorites").ToString
value = String.Concat(value, "\", NameUrl, ".url")
Dim fw As System.IO.StreamWriter = System.IO.File.CreateText(value)
fw.WriteLine("[InternetShortcut]")
fw.WriteLine(String.Concat("URL=", url))
fw.Close()
NV2002
January 11th, 2003, 05:30 PM
Thanks,
I will give the code a TRY...
What is the CODE to READ the current Entries on Disk
Nick
DdH
January 11th, 2003, 06:48 PM
Dim NameUrl As String
Dim Url As String
Dim key As Microsoft.Win32.RegistryKey
Dim value As String
key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\")
value = key.GetValue("Favorites").ToString
Dim file As System.IO.FileInfo
Dim dir As New System.IO.DirectoryInfo(value)
For Each file In dir.GetFiles("*.url")
NameUrl = file.Name.Replace(".url", "")
Dim fr As System.IO.StreamReader = System.IO.File.OpenText(file.FullName)
Url = fr.ReadLine
Do While Not (Url Is Nothing)
If Url.ToUpper.StartsWith("URL=") Then
Url = Url.Replace("URL=", "")
Exit Do
End If
Url = fr.ReadLine
Loop
fr.Close()
System.Windows.Forms.MessageBox.Show(Url, NameUrl)
Next
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.