private void EncryptFile() { // Information passed into encryption class in order to perform transformation RijndaelManagedEncryption myRij = new RijndaelManagedEncryption(); myRij.Files = FileToEncrypt; myRij.Password = UserPassword; myRij.NameOfFile = NameOfFile; // Returns path of encrypted file EncryptedFile = myRij.EncryptFile(); }
private void pnlDecrypt_DragDrop(object sender, DragEventArgs e) { if (e.Data.GetDataPresent(DataFormats.FileDrop)) { sfd.InitialDirectory = @"C:\"; sfd.DefaultExt = "sdx"; sfd.Filter = "Safe Dropbox files (*.sdx) | *.sdx"; string[] files = (string[])e.Data.GetData(DataFormats.FileDrop); //Strip out the file into an array foreach (string file in files) { var ext = Path.GetExtension(file); if (ext != ".sdx") { MessageBox.Show("File must be a Safe Dropbox file (.sdx)"); } else { // Get the path of the file and assign to FileToEncrypt property var fileName = Path.GetFullPath(file); FileToEncrypt = fileName; // Call my encryption class and pass the file into the EncryptFile() method RijndaelManagedEncryption myEncryption = new RijndaelManagedEncryption(); sfd.ShowDialog(); if (sfd.ShowDialog() == DialogResult.OK) { myEncryption.SaveFileLocation = sfd.FileName; } myEncryption.Files = FileToEncrypt; myEncryption.Password = UserPassword; EncryptedFile = myEncryption.DecryptFile(); } } } }