/// <summary> /// 登录成功,将用户账号保存到本地 /// </summary> private void SaveUserAcc() { try { FileStream fs = null; StreamWriter sw = null; string encryptuser = StringSecurity.DESEncrypt(usernameep); string encryptpw; fs = new FileStream(userSaveFiler, FileMode.OpenOrCreate); sw = new StreamWriter(fs); if (ischeck) { encryptpw = StringSecurity.DESEncrypt(pwp); } else { encryptpw = ""; } sw.WriteLine(encryptuser + "&" + encryptpw); sw.Close(); fs.Close(); } catch { } }
string pwp; //登录用户密码 public LoginWindow() { InitializeComponent(); if (File.Exists(userSaveFiler)) { //账号信息文件存在 StreamReader reader = new StreamReader(userSaveFiler); string acce = reader.ReadToEnd(); if (!acce.Trim().Equals("")) { string[] accearray = acce.Split('&'); username.Text = StringSecurity.DESDecrypt(accearray[0]); if (!accearray[1].Trim().Equals("")) { userpw.Password = StringSecurity.DESDecrypt(accearray[1]); jizhumima.IsChecked = true; } reader.Close(); } } }