private void DecryptWorkerProgressChanged(object sender, ProgressChangedEventArgs e)
 {
     if (e.UserState != null)
     {
         object[]         args             = (object[])e.UserState;
         PasswordValidity passwordValidity = (PasswordValidity)args[0];
         CurrentPassword = args[1].ToString();
         Speed           = (ulong)args[2];
         PasswordCount   = (ulong)args[3];
         if (passwordValidity != PasswordValidity.Invalid)
         {
             SelectedFile.SetPassword(CurrentPassword, passwordValidity);
             WriteToFile(passwordValidity, CurrentPassword);
             Status = string.Format("{0}: {1}", passwordValidity.ToString(), CurrentPassword);
         }
     }
 }
        private Task WriteToFile(PasswordValidity passwordValidity, string CurrentPassword)
        {
            string destinationFilePath = string.Empty;

            string summaryMsg = string.Format("{0},{1},{2}={3}{4}",
                                              DateTime.Now.ToString(CultureInfo.CurrentCulture),
                                              SelectedFile.Info.FullName, passwordValidity.ToString(),
                                              CurrentPassword, Environment.NewLine);
            FileMode fileMode = OverwritePasswordFile ? FileMode.Create : FileMode.Append;

            if (SaveOptionsPasswordFile == SaveOptions.UseSourceFolder)
            {
                destinationFilePath = string.Format("{0}\\{1}", SelectedFile.Info.DirectoryName, PasswordStorageFilename);
            }
            else if (SaveOptionsPasswordFile == SaveOptions.UseCustomFolder)
            {
                destinationFilePath = string.Format("{0}\\{1}", SelectedSavePath, PasswordStorageFilename);
            }

            return(FileHelpers.WriteToFileAsync(destinationFilePath, fileMode, summaryMsg));
        }