My effort to retrieve favicon.ico sometimes fails even though it is found. It fails when attempting to convert the stream into a BMP or an Image using FromStream(), with the ArgumentException, or Parameter Invalid. I've tried all kinds of things to manipulate this and I guess I don't know what I'm doing.

When I save the stream to a file (SaveStreamAsIconFile) as *.ico, it appears to be a valid icon (explorer displays it, and the IDE even shows it).

Here is a link that won't work, and also the code I am using to download and convert the stream:


public static Image GetFavIcon (Uri uriIcon)
            WebClient webClient = new WebClient();
            MemoryStream ms = new MemoryStream(webClient.DownloadData(uriIcon));

            MiscMethods.SaveStreamAsIconFile(ms, uriIcon.Host);
            ms.Position = 0;
            Bitmap bmp = new Bitmap(ms);

            return bmp;//Image.FromStream(ms);
8 Years
Discussion Span
Last Post by DdoubleD

When I try:

Image img = Image.FromFile(fileName);

I get a SystemException: "Out of Memory".

Admittedly, I don't know much concerning graphics. Can anybody tell me why this icon throws an exception? I have included it for examination.


Do not create duplicate thread for the same question.

Sorry, it won't happen again. I would have deleted this one if I could have. I just thought if I narrowed down the title/topic it might be easier found by someone knowledgeable with the Image class.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.