Esempio n. 1
0
        public static void LoadXML(bListNotes list)
        {
            XmlReaderSettings xms = new XmlReaderSettings();

            string[] files = Directory.GetFiles(notedir);
            string   title;
            string   date;
            string   mdate;
            string   file;
            int      i = 0;
            bool     _sync;

            using (XmlReader xm = XmlReader.Create("index.xml", xms))
            {
                xm.MoveToContent();

                while (xm.Read())
                {
                    if (xm.Name == "n")
                    {
                        if (xm.IsStartElement())
                        {
                            title = xm.GetAttribute("t");
                            file  = xm.GetAttribute("f");
                            date  = xm.GetAttribute("d");
                            mdate = xm.GetAttribute("md");
                            _sync = File.Exists(file);
                            list.Items.Add(new exListBoxItem(i, title, file, date, _sync));
                            i++;
                        }
                    }
                }
            }
        }
Esempio n. 2
0
        public static void ReadAll(bListNotes list)
        {
            XmlWriterSettings xmws = new XmlWriterSettings();

            xmws.Indent = true;
            string[] files = Directory.GetFiles(notedir);
            string   title;
            string   date;
            string   mdate;
            int      i = 0;

            using (XmlWriter xw = XmlWriter.Create("index.xml", xmws))
            {
                xw.WriteStartDocument();
                xw.WriteStartElement("notes");

                foreach (string file in files)
                {
                    if (File.Exists(file))
                    {
                        title = file.Substring(file.LastIndexOf("\\") + 1);
                        date  = File.GetCreationTime(file).ToString("ddMMyy");
                        mdate = File.GetLastWriteTime(file).ToString("ddMMyy");
                        list.Items.Add(new exListBoxItem(i, title, file, date, true));
                        i++;
                        xw.WriteStartElement("n");

                        xw.WriteAttributeString("t", title);
                        xw.WriteAttributeString("f", file);
                        xw.WriteAttributeString("d", date);
                        xw.WriteAttributeString("md", mdate);
                        xw.WriteEndElement();
                    }
                }

                xw.WriteEndElement();
                xw.WriteEndDocument();
                xw.Close();
            }
        }