DIDISOFT PGP шифрование файлов

Кто -нибудь знает, как изменить @"C:\Test\public_key.asc" от ручного ввода к использованию openfiledialog?

Я попытался сделать это, под кодом есть красная линия зизаг, и когда я наведу курсор мыши, он говорит, что не может преобразовать System.IO.FileInfo в System.IO.Stream.

using System.IO;
using DidiSoft.Pgp;

class EncryptDemo {
 public void Demo() {
     // create an instance of the library
     PGPLib pgp = new PGPLib();

     // specify should the output be ASCII or binary
     bool asciiArmor = false;
     // should additional integrity information be added
     // set to false for compatibility with older versions of PGP such as 6.5.8.
     bool withIntegrityCheck = false;

     pgp.EncryptFile(@"C:\Test\INPUT.txt",
                     @"C:\Test\public_key.asc",
                     @"C:\Test\OUTPUT.pgp",
                     asciiArmor,
                     withIntegrityCheck);
 }
}

Приведенное ниже не очень помогает нам, потому что оно не открывает диалоговое окно для выбора моего файла.

    bool asciiArmor = false;
    bool withIntegrityCheck = false;
    using (var publickey = new FileStream(openFileDialog1.FileName, FileMode.Open))
    {
        pgp.EncryptFile(@attachmentTextBox.Text, publickey, @"C:\OUTPUT.pgp", asciiArmor, withIntegrityCheck);
    }

1 ответ

Вы пробовали с:

bool asciiArmor = false;
bool withIntegrityCheck = false;
pgp.EncryptFile(@attachmentTextBox.Text, openFileDialog1.FileName, @"C:\OUTPUT.pgp", asciiArmor, withIntegrityCheck);
Другие вопросы по тегам