System.Drawing.Icon c = new Icon(@"c:\app\mapp\p1.ico");
pictureBox1.Image = c.ToBitmap();
I tried that--it did work. What I can't figure out is how to convert my Stream containing the icon (bitmap). I saved that icon to a file from the stream in order to narrow down the problem.
I don't understand why the Bitmap object initialization works from the file OK in this case, but not from my stream:
MemoryStream ms = new MemoryStream(webClient.DownloadData(uriIcon));
Bitmap bmp = new Bitmap(ms); // throws exception
But, if I save the memorystream above to a file, then read it with the code you gave, it works (no exception thrown).
This failure (ParameterInvalid exception) only occurs with certain icons I test, which is why I provided the sample. How can I convert this icon directly from my stream to a bitmap without having to save it to a file first?
No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.