Пример #1
0
        //-------------------------------------------------------------------------------------------------------
        private void btn_Unlock_Click(object sender, EventArgs e) //Button For Unlocking The Folder
        {
            try
            {
                if (textFileName.Text.Length > 0)
                {
                    DataAccessClass dac = new DataAccessClass();
                    bool            s   = dac.PassKey(txtPassFolder.Text);

                    if (s && txtPassFolder.Text.Length > 0)
                    {
                        DirectoryInfo d = new DirectoryInfo(path);
                        //string selectedpath = d.Parent.FullName + d.Name;


                        d.MoveTo(path.Substring(0, path.LastIndexOf("."))); // *****Move To A new Unlock FIlePath******
                        //txtFilePath.Text = txtFilePath.Text.Substring(0, txtFilePath.Text.LastIndexOf("."));
                        pictureBox1.Image = Image.FromFile(Application.StartupPath + "\\unlock.jpg");


                        dac.DeleteFolderLockList(textFileName.Text);        // *******Delete The FilePAth From Database*****
                        textFileName.Clear();
                        MessageBox.Show("Folder has been UnLocked!", "Congratulations!", MessageBoxButtons.OK);
                    }
                    else
                    {
                        MessageBox.Show("Please Enter the Correct Password", "Wrong Password", MessageBoxButtons.OK);
                    }
                }
                else
                {
                    MessageBox.Show("Please Browse the Folder First", "Invalid Input", MessageBoxButtons.OK);
                }
                txtPassFolder.Clear();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error!", MessageBoxButtons.OK);
            }
        }