Exemplo n.º 1
0
        private async Task ProcessFile(string file)
        {
            var shortFile = System.IO.Path.GetFileName(file);

            if (!string.IsNullOrEmpty(shortFile) && shortFile.Length > 35)
            {
                shortFile = shortFile.Substring(0, 32) + "...";
            }

            var prg = new Progress <StreamCryptorTaskAsyncProgress>();

            prg.ProgressChanged += (s, e) =>
            {
                status.Text = string.Format("{0}: {1}%", shortFile, e.ProgressPercentage);
            };

            try
            {
                Enabled = false;

                await MessageCrypto.DecryptFile(file, Common.KeyPair, prg);
            }
            catch (Exception ex)
            {
                MessageBox.Show(
                    string.Format("Unable to decrypt message. Please verify that it is correct. \r\nError: '{0}'", ex.Message),
                    "CurveLock Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }