2

I've looked around for an answer to this for quite some time.

I need to convert an icon to a byte[] in .NETCF but there is no icon.save() function in compact framework to create a MemoryStream object. What is another way that I can do this?

Thanks

Zac
  • 2,325
  • 3
  • 23
  • 33

3 Answers3

2

There's two things I can think of, one of them is suggested by Christian, the other one is that if it is a resource, can't you get a ResourceStream? This works if you make the icon an Embedded Resource (example found here)

This SO thread also discusses something not unlike your problem.

Community
  • 1
  • 1
Jonas Van der Aa
  • 1,441
  • 12
  • 27
  • The resourcestream is what I needed since they are each different filetypes and not in .ico format. Thanks! – Zac Apr 15 '11 at 17:53
1

Is it possible to call Icon.ToBitmap() and then read the bytes from the bitmap?

Hulk
  • 11
  • 1
  • Unfortunately no :/ There's no methods within the compact framework's Icon class to do a ToBitmap() or Save()... – Zac Apr 05 '11 at 23:35
1

If all you need is the raw bytes of the .Ico file then you can just read it directly with a file stream