I'm making a small application to get more familiar with serialisation. I'm currently trying to serialize an image using xml. So far I've just created a property that will do the serialization. However I'm not sure where to go from here and what I should do next.
I want to be able to tell it what image to serialize and run it from my Main method in my console application
My code is as follows
[XmlIgnore]
public static Bitmap LargeIcon { get; set; }
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
[XmlElement("LargeIcon")]
public byte[] LargeIconSerialized
{
get
{ // serialize
if (LargeIcon == null) return null;
using (MemoryStream ms = new MemoryStream())
{
LargeIcon.Save(ms, ImageFormat.Bmp);
return ms.ToArray();
}
}
set
{ // deserialize
if (value == null)
{
LargeIcon = null;
}
else
{
using (MemoryStream ms = new MemoryStream(value))
{
LargeIcon = new Bitmap(ms);
}
}
}
}