zoukankan      html  css  js  c++  java
  • XmlSerializer序列化一组成员到文本文件

    写入:

    using (System.IO.IsolatedStorage.IsolatedStorageFile isf = System.IO.IsolatedStorage.IsolatedStorageFile.GetUserStoreForApplication())
                {
                    using (System.IO.IsolatedStorage.IsolatedStorageFileStream fs = isf.CreateFile(fileName))
                    {
                        System.Xml.Serialization.XmlSerializer ser = new System.Xml.Serialization.XmlSerializer(typeof(List<TripInfo>));
                        ser.Serialize(fs, Trips);
                    }
                }

    读取:

    List<TripInfo> trips = null;
                System.Xml.Serialization.XmlSerializer ser = new System.Xml.Serialization.XmlSerializer(typeof(List<TripInfo>));
                object obj = ser.Deserialize(fs);
                if (null != obj && obj is List<TripInfo>)
                {
                    trips = obj as List<TripInfo>;
                }
                else
                {
                    trips = new List<TripInfo>();
                }

  • 相关阅读:
    .net log4dll的使用
    Myslq 5.7安装
    接口和抽象类有什么区别
    monkey测试
    JDK、Jmeter、Android环境变量配置
    聊天室
    tushrea知识笔记
    爬取图片
    python gui之tkinter事件处理
    ttk.Treeview
  • 原文地址:https://www.cnblogs.com/binaryworms/p/2620456.html
Copyright © 2011-2022 走看看