不清楚,应该自己写程序来生成xml文件并写代码读吧!

解决方案 »

  1.   

    我觉的肯定是可以实现的,关键是要懂的怎样去读写XML文件了,你在网上搜一下一大把例子
      

  2.   

    这个用SoapFormatter就可以了吧,序列化一下最后出来的就是Xml格式
      

  3.   

    另外还可以先用BinaryFormatter序列化成两进制数据然后随便创建一个Xml文件,把两进制数据保存到Xml的一个节点中也行啊
      

  4.   

    竟然在陈年旧账中翻到一段代码,那就顺便贴一下好了反正以前在MS新闻组也贴过的/**
     *  功能说明:  试验字体对象序列化/反序列化
     *              发现字体对象无法正常反序列化
     *  例    子:  
     *              
     *  作    者:  lugi
     *  创建时间:  2004年01月28日
     *  修改历史:  
     *  Copyright (C) 2001 LugiSoft Software Inc. All rights reserved.
     */
     
    namespace Leaf.Experiment
    {
        using System;
        using System.Drawing;
        using System.IO;
        using System.Xml;
        using System.Windows.Forms;
        using System.Runtime.Serialization.Formatters.Soap;
        using System.Text;
        
        public class FontSerial
        {
            public static void Main(string [] args)
            {
                MemorySerialObject((int)12345);
                FileSerialObject((int)12345);
                
                MemorySerialObject(SystemInformation.WorkingArea);
                FileSerialObject(SystemInformation.WorkingArea);
                
                MemorySerialObject(SystemIcons.Hand);
                FileSerialObject(SystemIcons.Hand);
                
                // 下面四个均无法成功
                // MemorySerialObject(SystemInformation.MenuFont);
                // FileSerialObject(SystemInformation.MenuFont);
                // MemorySerialObject(new Font("宋体",14));
                // FileSerialObject(new Font("宋体",14));
            }
            
            // 把对象序列化到文件中,然后从文件数据中反序列化
            private static void FileSerialObject(object obj)
            {
                SoapFormatter format = new SoapFormatter();
                
                using(FileStream fs = new FileStream("c:\\tmp.soap", FileMode.Create))
                {
                    format.Serialize(fs,obj);
                    fs.Close();
                }
                
                using(FileStream fs = new FileStream("c:\\tmp.soap", FileMode.Open))
                {
                    object tmp = format.Deserialize(fs);
                    Console.WriteLine(tmp);
                    fs.Close();
                }
                
            }
            
            // 把对象序列化到内存中,然后从内存中反序列化
            private static void MemorySerialObject(object obj)
            {
                SoapFormatter format = new SoapFormatter();
                string s = null;
                
                using(MemoryStream ms = new MemoryStream())
                {
                    format.Serialize(ms,obj);
                    s = System.Text.Encoding.UTF8.GetString(ms.ToArray());
                    Console.WriteLine(s);
                }
                
                format = new SoapFormatter();
                using(MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(s)))
                {
                    object tmp = format.Deserialize(ms);
                    Console.WriteLine(tmp);
                }
            }
        }
    }