删除加密和发送的文件
本文关键字:文件 加密 删除 | 更新日期: 2023-09-27 18:37:22
我有这个电子邮件程序,我可以在其中加密数据(邮件的附件和正文)并通过网络发送。
我有一个encryptcheckbox
,当选中并单击sendbutton
时,附件是消息被加密并发送给收件人。
我使用滴滴软件pgp.dll文件来引用加密和解密算法。
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);
}
}
@"C:''Test''OUTPUT.pgp"部分,它实际上在我的计算机中创建加密文件附件(为什么你想要加密文件?所以,我的目的是让它创建,但在单击sendbutton
后(换句话说,在我的邮件发送后)将其删除。
您可以在
send
操作完成后使用 System.IO
中的 File
类将其删除:
if(File.Exists(@"C:'Test'OUTPUT.pgp"))
{
File.Delete(@"C:'Test'OUTPUT.pgp");
}