예제 #1
0
        internal List <objAccount> GetFileText()
        {
            FileExists();
            StringBuilder     sb   = new StringBuilder();
            List <objAccount> list = new List <objAccount>();

            using (StreamReader sr = new StreamReader(Path, Encoding.Default))
            {
                string line;
                while ((line = sr.ReadLine()) != null)
                {
                    sb.Append(line);
                }
            }
            string Fileline = BUDecrypt(sb.ToString());

            string[] GroupStringFather = Fileline.Split('&');
            foreach (string item in GroupStringFather)
            {
                string[] GroupStringSon = item.Split('^');
                if (GroupStringSon.Length >= 3)
                {
                    objAccount obj = new objAccount();
                    obj.Account  = GroupStringSon[0];
                    obj.AppName  = GroupStringSon[1];
                    obj.Password = GroupStringSon[2];
                    list.Add(obj);
                }
            }
            return(list);
        }
예제 #2
0
 internal bool AddFileText(objAccount account)
 {
     try
     {
         FileExists();
         using (FileStream fs = File.OpenWrite(Path))
         {
             using (StreamWriter sw = new StreamWriter(fs))
             {
                 sw.Write(BUEncrypt(account.ToString()));
                 return(true);
             }
         }
     }
     catch (Exception e)
     {
         return(false);
     }
 }
예제 #3
0
        private void btSave_Click(object sender, EventArgs e)
        {
            objAccount obj = new objAccount();

            obj.Account  = tbAccount.Text;
            obj.AppName  = tbAppName.Text;
            obj.Password = tbPassword.Text;
            if (filehelper.AddFileText(obj))
            {
                tbAccount.Text  = "";
                tbAppName.Text  = "";
                tbPassword.Text = "";
                lbmsg.Text      = "保存成功!";
            }
            else
            {
                lbmsg.Text = "保存失败!";
            }
        }