예제 #1
0
        private void bEdit_Click(object sender, EventArgs e)
        {
            foreach (ListViewItem lvi in lvC.SelectedItems)
            {
                String fp = (String)lvi.Tag;
                if (fp == null)
                {
                    return;
                }

                XmlSerializer xmls = new XmlSerializer(typeof(Conn));
                Conn          conn;
                using (FileStream fs = File.OpenRead(fp)) {
                    conn = (Conn)xmls.Deserialize(fs);
                }
                using (ConnForm form = new ConnForm(conn)) {
                    form.tbFName.Text = Path.GetFileNameWithoutExtension(fp);
                    if (form.ShowDialog() == DialogResult.OK)
                    {
                        File.Delete(fp);
                        fp = Path.Combine(Path.GetDirectoryName(fp), form.tbFName.Text + Resources.FExt);
                        using (FileStream fs = File.Create(fp)) {
                            xmls.Serialize(fs, conn);
                        }
                    }
                }
                break;
            }
            Upt();
        }
예제 #2
0
        private void bNew_Click(object sender, EventArgs e)
        {
            Conn conn = new Conn();

            using (ConnForm form = new ConnForm(conn)) {
                if (form.ShowDialog() == DialogResult.OK)
                {
                    XmlSerializer xmls = new XmlSerializer(typeof(Conn));
                    using (FileStream fs = File.Create(Path.Combine(BaseDir, form.tbFName.Text + Resources.FExt))) {
                        xmls.Serialize(fs, conn);
                    }
                }
            }
            Upt();
        }