private void btnDecrypt_Click(object sender, EventArgs e) { string ToDecrypt = ""; try { try { ToDecrypt = FilePath + lbFiles.SelectedItem.ToString(); } catch (Exception) { MessageBox.Show("You must select an item to encrypt or decrypt!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (string.IsNullOrWhiteSpace(txtPassword.Text)) { MessageBox.Show("You must enter a password to decrypt or encrypt files!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } string Password = txtPassword.Text; if (Path.GetExtension(ToDecrypt).ToLower() == ".locked") { } else { MessageBox.Show("File is already decrypted!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } string Output = FilePath + Path.GetFileNameWithoutExtension(ToDecrypt); Rijndael.Decrypt(ToDecrypt, Output, txtPassword.Text, KS); File.Delete(ToDecrypt); WriteToConsole("Decrypted file successfully"); } catch { File.Delete(FilePath + Path.GetFileNameWithoutExtension(ToDecrypt)); } }