private void SaveUserInfo( ) { string file = Path.Combine( AppDomain.CurrentDomain.BaseDirectory, ConstUserInfoFile ); string account = RememberUserName ? AccountName : string.Empty; string password = RememberPassword ? PbPassword.Password : string.Empty; UserInformation userInfo = new UserInformation { AccountName = account, Password = password, RememberUserName = RememberUserName, RememberPassword = RememberPassword, AccType = AccType, }; userInfo.Encrypt( ); bool ret = FileSerialize<UserInformation>.Serialize( userInfo, file ); if( ret ) { FileInfo fileInfo = new FileInfo( file ); fileInfo.Attributes = FileAttributes.Hidden; } }
private void InitializeUserInfo( ) { string file = Path.Combine( AppDomain.CurrentDomain.BaseDirectory, ConstUserInfoFile ); UserInformation userInfo; if( File.Exists( file ) ) { userInfo = FileSerialize<UserInformation>.Deserialize( file ); userInfo.Decrypt( ); } else userInfo = new UserInformation( ); AccountName = userInfo.AccountName; PbPassword.Password = userInfo.Password; AccType = userInfo.AccType; RememberPassword = userInfo.RememberPassword; RememberUserName = userInfo.RememberUserName; }