Exemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            UserPassIpPort upip1 = new UserPassIpPort();

            if (textBox1.Text == "" || textBox2.Text == "" || textBox3.Text == "" || textBox4.Text == "")
            {
                MessageBox.Show("各项均不能为空!");
            }
            else
            {
                if (firstloginflag)
                {
                    FileStream   loginflagfs = new FileStream(@"firstloginflag.txt", FileMode.Create);
                    StreamWriter loginflagsw = new StreamWriter(loginflagfs);
                    loginflagsw.Write("1");
                    loginflagsw.Close();
                    loginflagfs.Close();
                }
                upip1.ipAddress = textBox3.Text;
                upip1.port      = textBox4.Text;
                upip1.userName  = textBox1.Text;
                upip1.passWord  = textBox2.Text;
                string       stringupip = new JavaScriptSerializer().Serialize(upip1);
                FileStream   fs         = new FileStream(@"upip1.txt", FileMode.Create);
                StreamWriter sw         = new StreamWriter(fs);
                sw.Write(stringupip);
                sw.Close();
                fs.Close();
                MessageBox.Show(stringupip + "----保存成功!");
            }
        }
Exemplo n.º 2
0
        private void changeunpw_Load(object sender, EventArgs e)
        {
            string strduqu             = File.ReadAllText(@"upip1.txt");
            JavaScriptSerializer js2   = new JavaScriptSerializer();
            UserPassIpPort       upip2 = js2.Deserialize <UserPassIpPort>(strduqu);

            textBox3.Text = upip2.ipAddress;
            textBox4.Text = upip2.port;
            textBox1.Text = upip2.userName;
            textBox2.Text = upip2.passWord;
        }