//Button for Unlocking --------------------------------------------------------------------------------------------- private void btn_UnLock_Click(object sender, EventArgs e) { try { DataAccessClass dac = new DataAccessClass(); Boolean bl = dac.PassKey(txt_Pass.Text); if (bl) { 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); if (s) { count++; } } if (count == files.Length) { MessageBox.Show(count + " Files Have been Unlocked!!", "Congratzz!!", MessageBoxButtons.OK); } else { MessageBox.Show("The Folder Has not Unlocked Properly!", "Error", MessageBoxButtons.OK); } DataAccessClass ndc = new DataAccessClass(); ndc.DeleteHighFolder(txt_FolderPath.Text); txt_FolderPath.Clear(); txt_Pass.Clear(); } } catch (Exception ex) { MessageBox.Show("Invalid Input...", "Error!", MessageBoxButtons.OK); } }