コード例 #1
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            main.Login(string.Format(DataStrFormat, comService.Text, comDataBase.Text, comLoginName.Text, comLoginPwd.Text), this);
            loginBox box = new loginBox();

            box.Service   = comService.Text;
            box.LoginName = comLoginName.Text;
            box.LoginPwd  = comLoginPwd.Text;
            SaveLoginString(box);
            this.Close();
        }
コード例 #2
0
        private void SaveLoginString(loginBox box)
        {
            StreamReader file    = new StreamReader("Login.logtext");
            string       boxText = file.ReadToEnd();

            file.Close();
            List <loginBox> listBox = JsonConvert.DeserializeObject <List <loginBox> >(boxText);

            if (listBox == null)
            {
                listBox = new List <loginBox>();
            }
            if (listBox.Where(b => b.Service == box.Service && b.LoginName == box.LoginName && b.LoginPwd == box.LoginPwd).Count() == 0)
            {
                listBox.Add(box);
                string       saveString = JsonConvert.SerializeObject(listBox);
                StreamWriter writ       = File.CreateText("Login.logtext");
                writ.WriteLine(saveString);
                writ.Close();
            }
        }