Ejemplo n.º 1
0
        private void EncryptionDriveThread()
        {
            string[] Files = { };
            this.Dispatcher.Invoke(() =>
            {
                Files = Directory.GetFiles(DriveEncryptionListBox.SelectedItem.ToString(), "*", SearchOption.AllDirectories);
            });


            foreach (string i in Files)
            {
                this.Dispatcher.Invoke(() =>
                {
                    try
                    {
                        FileEncryption.EncryptFile(i, i + "Crypt", FolderEncryptionPassword.Password);
                        CryptStatus.Document.Blocks.Add(new Paragraph(new Run("File Encrypted :" + i)));
                        File.Delete(i);
                    }
                    catch (Exception Ex)
                    {
                        ErrorBox(Ex.Message);
                    }
                });
            }
            this.Dispatcher.Invoke(() =>
            {
                CryptStatus.Document.Blocks.Add(new Paragraph(new Run("\n")));
            });
        }
Ejemplo n.º 2
0
        private void DriveEncryptionbgWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            List <string> agms = e.Argument as List <string>;;

            string[] Files = { };
            try
            {
                Files = Directory.GetFiles(agms[0], "*", SearchOption.AllDirectories);
                this.Dispatcher.Invoke(() =>
                {
                    CryptStatus.Document.Blocks.Add(new Paragraph(new Run("Encryption Terminated.\n")));
                });
            }
            catch
            {
                ErrorBox("No drive selected");
                return;
            }
            foreach (string i in Files)
            {
                if (i.Contains(".Crypt"))
                {
                    ErrorBox("This drive contains files that are already encrypted.\nDecrypt those and retry encryption");
                    this.Dispatcher.Invoke(() =>
                    {
                        CryptStatus.Document.Blocks.Add(new Paragraph(new Run("Encryption Terminated.\n")));
                    });
                    return;
                }
            }
            foreach (string i in Files)
            {
                try
                {
                    FileEncryption.EncryptFile(i, i + ".Crypt", agms[1]);
                    this.Dispatcher.Invoke(() =>
                    {
                        CryptStatus.Document.Blocks.Add(new Paragraph(new Run("File Encrypted :" + i)));
                    });
                    File.Delete(i);
                }
                catch (Exception Ex)
                {
                    ErrorBox(Ex.Message);
                }
            }
            this.Dispatcher.Invoke(() =>
            {
                CryptStatus.Document.Blocks.Add(new Paragraph(new Run("Drive Encryption Completed.\n")));
                SuccessBox("Drive Encryption Completed.");
            });
        }
Ejemplo n.º 3
0
        void FileEncryptionbgWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            List <string> agms = e.Argument as List <string>;

            FileEncryption.EncryptFile(agms[0], agms[0] + ".Crypt", agms[1]);
            if (agms[2].Equals("Delete"))
            {
                File.Delete(agms[0]);
            }
            this.Dispatcher.Invoke(() =>
            {
                CryptStatus.Document.Blocks.Add(new Paragraph(new Run("File Encrypted :" + FileEncNameDisplay.Text + "\n")));
                SuccessBox("File Encrypted :" + FileEncNameDisplay.Text);
            });
        }
Ejemplo n.º 4
0
 private void EncryptFile_Click(object sender, RoutedEventArgs e)
 {
     if (FileEncNameDisplay.Text.Equals("Not selected"))
     {
         ErrorBox("No File Selected");
     }
     else
     {
         CryptStatus.Document.Blocks.Add(new Paragraph(new Run("Encrypting... Please wait")));
         FileEncryption.EncryptFile(FileEncNameDisplay.Text, FileEncNameDisplay.Text + "Crypt", FileEncryptionPassword.Password);
         if (!(bool)CheckFileEnc.IsChecked)
         {
             File.Delete(FileEncNameDisplay.Text);
         }
         CryptStatus.Document.Blocks.Add(new Paragraph(new Run("File Encrypted :" + FileEncNameDisplay.Text + "\n")));
     }
 }