Font font = new Font("宋体", 16f);
IFormatter formatter = new BinaryFormatter();
Stream stream = new FileStream(@"D:/MyFile.bin", FileMode.OpenOrCreate,
FileAccess.Write, FileShare.None);
//通过formatter对象以二进制格式将obj对象序列化后到文件MyFile.bin中
formatter.Serialize(stream,font);
stream.Close();
//重新取回数据
Stream stream2 = new FileStream(@"D:/MyFile.bin", FileMode.Open,
FileAccess.Read, FileShare.None);
Font font2=(Font)formatter.Deserialize(stream2);
stream2.Close();
MessageBox.Show(font2.FontFamily.ToString());