示例#1
0
        public static void SaveTaskDBEntry(TaskDBEntry _task)
        {
            XmlSerializer serializer =
                new XmlSerializer(typeof(TaskDBEntry));
            TextWriter writer = new StreamWriter("tasks\\" + _task.Name + ".xml");

            serializer.Serialize(writer, _task);
            writer.Close();
        }
示例#2
0
        private static TaskDBEntry LoadDB(string filename)
        {
            XmlSerializer serializer = new XmlSerializer(typeof(TaskDBEntry));

            // If the XML document has been altered with unknown
            // nodes or attributes, handles them with the
            // UnknownNode and UnknownAttribute events.
            serializer.UnknownNode += new
                                      XmlNodeEventHandler(serializer_UnknownNode);
            serializer.UnknownAttribute += new
                                           XmlAttributeEventHandler(serializer_UnknownAttribute);

            FileStream fs = new FileStream(filename, FileMode.Open);

            TaskDBEntry _task = (TaskDBEntry)serializer.Deserialize(fs);

            fs.Close();
            //_task.Name = new FileInfo(filename).Name;
            return(_task);
        }