private void btnDecrypt_Click(object sender, EventArgs e) { try { //to decrypt the file if (string.IsNullOrEmpty(txtFolderName.Text)) { throw new Exception("Select output folder"); } if (string.IsNullOrEmpty(txtFilePath.Text)) { throw new Exception("Select File to decrypt"); } if (string.IsNullOrEmpty(decrypExtension)) { throw new Exception("Select file decryption extention"); } dataCryptor.FileDetails(info.Name.Substring(0, info.Name.Length - info.Extension.Length), info.Extension, decrypExtension); dataCryptor.isDeletePlainFile(deleteFile); dataCryptor.DecryptFile(); MessageBox.Show("Decryption Successfull", "Completed"); checkDeleteFile.Checked = false; txtFilePath.Clear(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Decryption Error"); } }
private void btnimport_Click(object sender, EventArgs e) { try { lbInfor.Visible = true; //to decrypt the file if (string.IsNullOrEmpty(txtFileName.Text)) { throw new Exception("Select output folder"); } var dbname = txtFileName.Text.Substring(0, txtFileName.Text.LastIndexOf(".")).ToLower(); if (dbname == "cashdeskdb") { encFileExtension = ".mdf"; encFileName = "CASHDESKDB"; } else if (dbname == "cashdeskdb_log") { encFileExtension = ".ldf"; encFileName = "CASHDESKDB_log"; } dataCryptor.FileDetails(info.Name.Substring(0, info.Name.Length - info.Extension.Length), info.Extension, encFileExtension); dataCryptor.isDeletePlainFile(deleteFile); dataCryptor.DecryptFile(); File.SetAttributes(decrepted_file_path + "\\" + encFileName + encFileExtension, FileAttributes.Hidden); MessageBox.Show("Import Successfull", "Completed"); lbInfor.Visible = false; } catch (UnauthorizedAccessException) { MessageBox.Show("Access denied", "Import Error", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show(ex.Message, "Import Error", MessageBoxButtons.OK, MessageBoxIcon.Information); lbInfor.Visible = false; } }