public void Cipher(PublicKey publicKey, IList <FileSystemEntity> inputFileEntities, string outputFileName)
        {
            if (inputFileEntities.Count == 0)
            {
                throw new ArgumentException(@"inputFileEntities is empty", "inputFileEntities");
            }
            var temporaryFileName = environmentHelper.GetTempFileName();

            try {
                fileUnifier.Union(inputFileEntities, temporaryFileName);
                rsaFileCipher.Cipher(publicKey, temporaryFileName, outputFileName);
                if (rsaFileCipher.Status == ProcessStatus.Stopped)
                {
                    messageHelper.Show("Process was stopped.", "Процесс был остановлен.");
                    rsaFileCipher.Restart();
                }
                if (rsaFileCipher.Status == ProcessStatus.Complete)
                {
                    messageHelper.Show("Process complete.", "Процесс завершен.");
                }
            } catch (SourceFileNotFoundException) {
                messageHelper.Show("Source file not found.", "Исходный файл не найден.");
            } catch (UnauthorizedAccessSourceFileException) {
                messageHelper.Show("Error when accessing the source file.", "Ошибка доступа к исходному файлу.");
            } catch (DestinationFileException) {
                messageHelper.Show("Error writing RSA file.", "Ошибка при записи RSA файла");
            } finally {
                environmentHelper.DeleteFile(temporaryFileName);
            }
        }
示例#2
0
 public void Restart()
 {
     rsaFileCipher.Restart();
 }