//Button for Unlocking --------------------------------------------------------------------------------------------- private void btn_UnLock_Click(object sender, EventArgs e) { try { DataAccessClass dac = new DataAccessClass(); //Boolean bl = dac.PassKey(txt_Pass.Text); Boolean bl = true; if (bl) { if (txtEcryptPass.Text.Length == 8) { DirectoryInfo d = new DirectoryInfo(fpath); //string selectedpath = d.Parent.FullName + d.Name; if (fpath.LastIndexOf(".{") == -1) { MessageBox.Show("Folder IS Already Unlocked", "NO NEED", MessageBoxButtons.OK); } else { d.MoveTo(fpath.Substring(0, fpath.LastIndexOf("."))); } //string filename = fpath.ToString(); //txtFilePath.Text = txtFilePath.Text.Substring(0, txtFilePath.Text.LastIndexOf(".")); pictureBox1.Image = Image.FromFile(Application.StartupPath + "\\unlock.jpg"); MessageBox.Show("Folder has been UnLocked!", "Congratulations!", MessageBoxButtons.OK); string[] files = Directory.GetFiles(txt_FolderPath.Text, "*.*", SearchOption.AllDirectories); //Console.WriteLine("The number of directories starting with p is {0}.", folders.Length); MessageBox.Show("There Are " + files.Length + " files in the diretory....", "Nice!!", MessageBoxButtons.OK); int count = 0; foreach (string file in files) { LogicClass lgCs = new LogicClass(); Boolean s = lgCs.DecryptingMethod(file, txtEcryptPass.Text); if (s) { count++; } } if (count == files.Length) { MessageBox.Show(count + " Files Have been Unlocked!!", "Congratzz!!", MessageBoxButtons.OK); //DataAccessClass ndc = new DataAccessClass(); dac.DeleteHighFolder(txt_FolderPath.Text); dac.DeleteHighFolderPassword(txt_FolderPath.Text); txt_FolderPath.Clear(); } else { MessageBox.Show("The Folder Has not Unlocked Properly!", "Error", MessageBoxButtons.OK); } } else { if (txtEcryptPass.Text.Length < 8) { MessageBox.Show("Password is too short. Password must be a 8-character key.", "Invalid Input!", MessageBoxButtons.OK); } else { MessageBox.Show("Password is too large. Password must be a 8-character key.", "Invalid Input!", MessageBoxButtons.OK); } } } else { MessageBox.Show("Locker password is wrong! Please enter the correct one.", "Wrong Password!", MessageBoxButtons.OK); } txt_Pass.Clear(); txtEcryptPass.Clear(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error!", MessageBoxButtons.OK); } }