任何人都知道如何将@"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);
}
答案 0 :(得分:1)
您是否尝试过:
bool asciiArmor = false;
bool withIntegrityCheck = false;
pgp.EncryptFile(@attachmentTextBox.Text, openFileDialog1.FileName, @"C:\OUTPUT.pgp", asciiArmor, withIntegrityCheck);