Exemple #1
0
        //=========================================
        // loadWatchList
        //=========================================
        bool loadWatchList(string filename)
        {
            Stream st = null;

            try
            {
                XmlSerializer s = new XmlSerializer(typeof(WatchListXML), new Type[] { });
                st = File.OpenRead(filename);
                WatchListXML wlXML = (WatchListXML)s.Deserialize(st);
                st.Close();

                for (int i = 0; i < wlXML.mFiles.Count; i++)
                {
                    addElement(wlXML.mFiles[i].Filename);
                }
            }
            catch (Exception e)
            {
                MessageBox.Show("Error Loading " + filename + ":\n" + e.InnerException.ToString());

                if (st != null)
                {
                    st.Close();
                }

                if (File.Exists(filename))
                {
                    File.Delete(filename);
                }

                return(false);
            }

            return(true);
        }
Exemple #2
0
        //=========================================
        // saveCurrentWatchList
        //=========================================
        bool saveCurrentWatchList(string filename)
        {
            try
            {
                if (File.Exists(filename))
                {
                    File.Delete(filename);
                }

                WatchListXML wlXML = new WatchListXML();
                for (int i = 0; i < this.flowLayoutPanel1.Controls.Count; i++)
                {
                    FileTimelineElement pEle = (FileTimelineElement)this.flowLayoutPanel1.Controls[i];
                    if (pEle == null)
                    {
                        continue;
                    }


                    WatchFileXML wfXML = new WatchFileXML();
                    wfXML.Filename = pEle.getFilename();
                    wlXML.mFiles.Add(wfXML);
                }

                XmlSerializer s  = new XmlSerializer(typeof(WatchListXML), new Type[] { });
                Stream        st = File.Open(filename, FileMode.OpenOrCreate);
                s.Serialize(st, wlXML);
                st.Close();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.InnerException.ToString());
                return(false);
            }

            return(true);
        }