/// <summary> /// Read file with account data. /// </summary> /// <returns><see cref="Account"/> instance.</returns> private void ReloadAccount() { if (Pri.LongPath.File.Exists(Constants.PathToPasswordsFile)) { try { var waitHandleName = Constants.PathToPasswordsFile.GetHashString <SHA256Managed>(); using (var waitHandleLocker = EventWaitHandleLocker.MakeWithEventHandle(true, EventResetMode.AutoReset, waitHandleName)) { using (var fileStream = Pri.LongPath.File.Open(Constants.PathToPasswordsFile, FileMode.Open)) { using (StreamReader streamReader = new StreamReader(fileStream)) { try { var fromFileEncrypted = streamReader.ReadToEnd(); var fromFileDecrypted = TripleDESHelper.DecryptString(fromFileEncrypted); CurrentAccount = JsonConvert.DeserializeObject <Account>(fromFileDecrypted); } catch (Exception ex) { Logger.HandleException(ex); if (CurrentAccount is null) { CurrentAccount = new Account(); } } } } } } catch (Exception ex) { Logger.Error(ex.ToString()); } } }