Example #1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            string strduqu               = File.ReadAllText(@"cac.txt");
            JavaScriptSerializer js2     = new JavaScriptSerializer();
            CodeAndComport       cacduqu = js2.Deserialize <CodeAndComport>(strduqu);

            this.textBox2.Text = cacduqu.openscreen1;
            this.textBox3.Text = cacduqu.closescreen1;
            this.textBox5.Text = cacduqu.openscreen2;
            this.textBox4.Text = cacduqu.closescreen2;
            this.textBox8.Text = cacduqu.openscreen3;
            this.textBox7.Text = cacduqu.closescreen3;
        }
Example #2
0
        private void button13_Click(object sender, EventArgs e)
        {
            CodeAndComport cac = new CodeAndComport();

            cac.comport1     = "";
            cac.openscreen1  = this.textBox2.Text;
            cac.closescreen1 = this.textBox3.Text;
            cac.comport2     = "";
            cac.openscreen2  = this.textBox5.Text;
            cac.closescreen2 = this.textBox4.Text;
            cac.comport3     = "";
            cac.openscreen3  = this.textBox8.Text;
            cac.closescreen3 = this.textBox7.Text;

            string output = new JavaScriptSerializer().Serialize(cac);

            FileStream   fs = new FileStream(@"cac.txt", FileMode.Create);
            StreamWriter sw = new StreamWriter(fs);

            sw.Write(output);
            sw.Close();
            fs.Close();
            MessageBox.Show(output + "----保存成功!");
        }