示例#1
0
        private void LoginForm_Load(object sender, EventArgs e)
        {
            DirectoryInfo dir = new DirectoryInfo(SerializeUtil.Dir);

            if (!Directory.Exists(SerializeUtil.Dir))
            {
                Directory.CreateDirectory(SerializeUtil.Dir);
            }
            FileInfo[] infos = dir.GetFiles();
            //是否登录过
            if (infos.Length != 0) //是
            {
                foreach (FileInfo info in infos)
                {
                    //获得用户信息
                    User user = SerializeUtil.DeSerializeUser(info.FullName);
                    users.Add(user);
                    if (user.RemUser)
                    {
                        comboBox_username.Items.Add(user.Username);
                        comboBox_username.SelectedItem = user.Username;
                        if (user.RemPass)
                        {
                            checkBox2.Checked     = true;
                            textBox_password.Text = user.Password;
                        }
                        else
                        {
                            checkBox2.Checked = false;
                        }
                    }
                }
            }
        }
示例#2
0
        /// <summary>
        /// 是否登录过,记住了密码
        /// </summary>
        /// <returns>登录过返回对象,否则返回null</returns>
        public static bool IsEverLoggedIn()
        {
            DirectoryInfo dir = new DirectoryInfo(SerializeUtil.Dir);

            if (!Directory.Exists(SerializeUtil.Dir))
            {
                Directory.CreateDirectory(SerializeUtil.Dir);
            }
            FileInfo[] infos = dir.GetFiles();
            //是否登录过
            if (infos.Length != 0) //是
            {
                foreach (FileInfo info in infos)
                {
                    //获得用户信息
                    User user = SerializeUtil.DeSerializeUser(info.FullName);
                    if (user.isLogin)
                    {
                        POP3Client pop3Client = new POP3Client(user);
                        SMTPClient smtpClient = new SMTPClient(user);
                        DataService.pop3 = pop3Client;
                        DataService.smtp = smtpClient;
                        return(true);
                    }
                }
            }
            return(false);
        }