0

有人知道如何@"C:\Test\public_key.asc"从手动输入更改为使用 openfiledialog 吗?

我试着这样做,代码下面有一条红色的 zizag 线,当我把鼠标放在上面时,它说它不能将 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);
    }
4

1 回答 1

1

您是否尝试过:

bool asciiArmor = false;
bool withIntegrityCheck = false;
pgp.EncryptFile(@attachmentTextBox.Text, openFileDialog1.FileName, @"C:\OUTPUT.pgp", asciiArmor, withIntegrityCheck);
于 2013-11-16T19:26:47.147 回答