Exemple #1
0
        private void saveFileButton_Click(object sender, RoutedEventArgs e)
        {
            SaveFileDialog dialog = new SaveFileDialog();

            dialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            //dialog.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
            if ((bool)dialog.ShowDialog())
            {
                File.WriteAllText(dialog.FileName, EncryptedDataHelper.ToFileFormat(encryptedFileContents));
            }
        }
Exemple #2
0
        private void selectFileToDecryptButton_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog();

            dialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);

            if ((bool)dialog.ShowDialog())
            {
                encryptionFilePath        = dialog.FileName;
                fileToDecryptTextBox.Text = encryptionFilePath;
                FileStream stream = File.OpenRead(encryptionFilePath);
                encryptionFileContents = new byte[stream.Length];
                try
                {
                    Dictionary <string, byte[]> test =
                        EncryptedDataHelper.ToDictionary(File.ReadAllText(encryptionFilePath));
                    encryptedFileContents = test;
                }
                catch (FormatException)
                {
                    SetDecryptionStatusMessage("Failed: Invalid file", Brushes.Red);
                }
            }
        }