private void encryptFileToolStripMenuItem_Click(object sender, EventArgs e)
{
FileInfo fi = new FileInfo(this.openFileDialog1.FileName);
if(!fi.Exists)
{
MessageBox.Show("File Not Found");
return;
}
if(fi.Attributes.ToString().Contains(FileAttributes.Encrypted.ToString()))
{
MessageBox.Show("File is already encrypted");
return;
}
if(MessageBox.Show("Are you sure you want to encrypt this file?\n\nOnly this user will be able to decrypt","File Peeker",MessageBoxButtons.YesNoCancel) == DialogResult.Yes)
{
fi.IsReadOnly = false;
try
{
fi.Encrypt();
fi.Refresh();
getFileInfo(fi);
}catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}