Пример #1
0
        public static List <Student> readXmlList(string filePath)
        {
            XmlSerializer xs = new XmlSerializer(typeof(StudentList));
            FileStream    fs = new FileStream(filePath, FileMode.Open, FileAccess.Read);
            StreamReader  sr = new StreamReader(fs);

            StudentList stdList = xs.Deserialize(sr) as StudentList;

            return(stdList.students);
        }
Пример #2
0
        public static void writeStudentListAsXml(string filePath, List <Student> studentList)
        {
            StudentList lst = new StudentList();

            lst.students = studentList;

            XmlSerializer xs = new XmlSerializer(typeof(StudentList));
            FileStream    fs = new FileStream(filePath, FileMode.Create, FileAccess.Write);
            StreamWriter  sw = new StreamWriter(fs);

            xs.Serialize(sw, lst);
        }