CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: Favorites

  1. #1
    Join Date
    Dec 2002
    Location
    USA
    Posts
    207

    Favorites

    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

  2. #2
    Join Date
    Jan 2003
    Location
    Amsterdam, Netherlands
    Posts
    97
    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()

  3. #3
    Join Date
    Dec 2002
    Location
    USA
    Posts
    207

    Read the Favorites

    Thanks,

    I will give the code a TRY...

    What is the CODE to READ the current Entries on Disk

    Nick

  4. #4
    Join Date
    Jan 2003
    Location
    Amsterdam, Netherlands
    Posts
    97
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured