Possible Duplicate:
How can I get a web site’s favicon?
I use these following codes to get the site favicon in a c# windows application to show that in a picture box.
HttpWebRequest web = (HttpWebRequest)HttpWebRequest.Create(downloadstring);
web.AllowAutoRedirect = true;
try
{
HttpWebResponse res = (HttpWebResponse)web.GetResponse();
System.Drawing.Image ico;
using (Stream s = res.GetResponseStream())
{
ico = System.Drawing.Image.FromStream(s);
}
pictureBox1.Image = ico;
}
catch (Exception)
{
}
The problem is it's gonna just show the favicon if it has been located in the main root server (for example www.example.com/favicon.ico
) but if the icon is in another folder it won't work.
How can I get the favicon if it is in any folder of the root server?