You are here:

C#/Font Serialization

Advertisement


Question
Hello.
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!

Answer
hi

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

C#

All Answers


Answers by Expert:


Ask Experts

Volunteer


Srini Nagarajan

Expertise

can answer any kind of questions in ASP.NET, C#, VB.NET, ASP, SharePoint 2007, Coldfusion, Powerbuilder 7.00 / 8.00, JAVA servlets, MS SQL 2000 / MSSQL7, Sybase

Experience

Contact me if you need any custom development on ASP.NET, ASP, Coldfusion, Powerbuilder

©2012 About.com, a part of The New York Times Company. All rights reserved.