示例#1
0
        public void Save(string name)
        {
            m_Xdoc.Load(m_Profile);
            XmlNode Node;

            Node = m_Xdoc.CreateComment(String.Format(" Auto-Profile Configuration Data. {0} ", DateTime.Now));
            foreach (XmlNode node in m_Xdoc.SelectNodes("//comment()"))
            {
                node.ParentNode.ReplaceChild(Node, node);
            }

            Node = m_Xdoc.SelectSingleNode("Programs");
            string programname;

            programname = Path.GetFileNameWithoutExtension(name);
            XmlElement el = m_Xdoc.CreateElement("Program");

            el.SetAttribute("path", name);
            el.AppendChild(m_Xdoc.CreateElement("Controller1")).InnerText = cBProfile1.Text;
            el.AppendChild(m_Xdoc.CreateElement("Controller2")).InnerText = cBProfile2.Text;
            el.AppendChild(m_Xdoc.CreateElement("Controller3")).InnerText = cBProfile3.Text;
            el.AppendChild(m_Xdoc.CreateElement("Controller4")).InnerText = cBProfile4.Text;
            try
            {
                XmlNode oldxmlprocess = m_Xdoc.SelectSingleNode("/Programs/Program[@path=\"" + lBProgramPath.Text + "\"]");
                Node.ReplaceChild(el, oldxmlprocess);
            }
            catch { Node.AppendChild(el); }
            m_Xdoc.AppendChild(Node);
            m_Xdoc.Save(m_Profile);
            if (lVPrograms.SelectedItems.Count > 0)
            {
                lVPrograms.SelectedItems[0].Checked = true;
            }
            form.LoadP();
        }