Reputation: 69
I have this email program where I encrypt the data (attachments and body of the message) and send it over the net.
I have a encryptcheckbox
, when checked AND sendbutton
is click, the attachments are message are encrypted and sent to the recipients.
I uses the didisoft pgp .dll files to have the reference of encryption and decryption algorithm.
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);
}
}
The part @"C:\Test\OUTPUT.pgp", it actually creates the encrypted file attachment in my computer (why would you want a encrypted file?). So, my intention was to let it create, but delete it after sendbutton
is clicked (in other words, after my mail is sent).
Upvotes: 0
Views: 220
Reputation: 3489
You can delete it using the File
class in System.IO
once your send
action is complete:
if(File.Exists(@"C:\Test\OUTPUT.pgp"))
{
File.Delete(@"C:\Test\OUTPUT.pgp");
}
Upvotes: 2