954,517 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

get icon of webpage

can someone tell me how to get the icon of a webpage. i can get the icon of a webpage and set it as an image but i want to take it and set it as the icon for my application. here is the code to get the icon and set it as a image

Dim url As Uri = New Uri(TextBox1.Text)

            If url.HostNameType = UriHostNameType.Dns Then
                ' Get the URL of the favicon
                ' url.Host will return such string as www.google.com
                Dim iconURL = "http://" & url.Host & "/favicon.ico"
                ' Download the favicon
                Dim request As System.Net.WebRequest = System.Net.HttpWebRequest.Create(iconURL)
                Dim response As System.Net.HttpWebResponse = request.GetResponse()
                Dim stream As System.IO.Stream = response.GetResponseStream()
                Dim favicon = Image.FromStream(stream)
                ' Display the favicon on PictureBox1
                PictureBox1.Image = favicon
            End If
choover12
Newbie Poster
22 posts since Sep 2010
Reputation Points: 10
Solved Threads: 0
 

try this
Icon = New Icon(stream)

ÜnLoCo
Light Poster
40 posts since Dec 2009
Reputation Points: 10
Solved Threads: 8
 

ok i tried

dim favicon = icon.fromstream(stream)


mabye that will work

choover12
Newbie Poster
22 posts since Sep 2010
Reputation Points: 10
Solved Threads: 0
 

sorry did'nt work

choover12
Newbie Poster
22 posts since Sep 2010
Reputation Points: 10
Solved Threads: 0
 

Add this to your code.

Dim iconBitmap As Bitmap = New Bitmap(favicon)
            Me.Icon = Icon.FromHandle(iconBitmap.GetHicon)
codeorder
Posting Virtuoso
1,913 posts since Aug 2010
Reputation Points: 255
Solved Threads: 384
 

thanks again codeorder.

choover12
Newbie Poster
22 posts since Sep 2010
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: