C#/Font Serialization
Expert: Srini Nagarajan - 4/25/2005
QuestionHello.
I am writing a c# program and i am using serialization to save an object to an xml file. one of the fields in that object is a Font object, which cannot be saved to the xml file "because it cannot be reflected" as the exception says.
How can i "reflect" the font object? or do i have to do something else in order to save it?
Thanks!
Answerhi
Try this
using System;
using System.Drawing;
using System.IO;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
public class tSeri
{
static void Main()
{
Font fnt = new Font("Courier", 10);
IFormatter formatter = new BinaryFormatter();
Stream stream = new FileStream("c:\\MyFont.bin",
FileMode.Create, FileAccess.Write, FileShare.None);
formatter.Serialize(stream, fnt );
stream.Close();
}
}
Happy Programming!!
-Srini