private void btnBackup_Click(object sender, EventArgs e) { try { if (string.IsNullOrEmpty(txtFolderName.Text)) { throw new Exception("Select folder to backup file"); } timer1.Enabled = true; timer1.Start(); FileInfo infor = new FileInfo(Application.StartupPath + "/CASHDESKDB.mdf"); info = new FileInfo(infor.FullName); dataCryptor.inPutFilePath(infor.FullName); dataCryptor.FileType(info.Extension); dataCryptor.FileType(info.Name.Substring(0, info.Name.Length - info.Extension.Length), info.Extension); dataCryptor.isDeletePlainFile(false); dataCryptor.EncryptFile(); FileInfo infor2 = new FileInfo(Application.StartupPath + "/CASHDESKDB_log.ldf"); info2 = new FileInfo(infor2.FullName); dataCryptor2.inPutFilePath(infor2.FullName); dataCryptor2.FileType(info2.Extension); dataCryptor2.FileType(info2.Name.Substring(0, info2.Name.Length - info2.Extension.Length), info2.Extension); dataCryptor2.isDeletePlainFile(false); dataCryptor2.EncryptFile(); MessageBox.Show("Backup Sucessfull", "Cashdesk", MessageBoxButtons.OK, MessageBoxIcon.Information); timer1.Stop(); pictureWait.Visible = false; lblWait.Visible = false; } catch (System.UnauthorizedAccessException) { MessageBox.Show("Access to File is denied for backup", "Cashdesk", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { pictureWait.Visible = false; lblWait.Visible = false; timer1.Stop(); MessageBox.Show(ex.Message, "Cashdesk", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void btnEncrypt_Click(object sender, EventArgs e) { try { if (string.IsNullOrEmpty(txtFolderName.Text)) { throw new Exception("Select output folder"); } if (string.IsNullOrEmpty(txtFilePath.Text)) { throw new Exception("Select File to encrypt"); } dataCryptor.isDeletePlainFile(deleteFile); dataCryptor.EncryptFile(); MessageBox.Show("Encryption Successful", "Completed"); checkDeleteFile.Checked = false; txtFilePath.Clear(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Encryption Error"); } }