Saturday 23 July 2011

C# Unlock Folder

At last section, we going to share about how to lock the folder. Now in this sections I going to share you about how we going to unlock the folder. This is also very simple where we only need to delete the CLSID.
Lock Folder add CLSID, unlock Folder delete CLSID.
How we going to delete the CLSID? We still using the rename mated to erase the CLSID.
Directory.MoveTo(folderBrowserDialog1.SelectedPath.Substring(0, folderBrowserDialog1.SelectedPath.LastIndexOf("."))); msdn

Programming Look Like
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.IO;

namespace Try_an_Error
{
    public partial class Form1 : Form
    {
        string WindowSecurity = ".{2559a1f2-21d7-11d4-bdaf-00c04f60b9f0}";
        public Form1()
        {
            InitializeComponent();
           
        }
       
        private void button1_Click(object sender, EventArgs e)
        {
           
            if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
            {
                if (folderBrowserDialog1.SelectedPath.LastIndexOf(".{") == -1)
                {
                    listBox1.Items.Add("true");
                    textBox1.Text = folderBrowserDialog1.SelectedPath;
                    DirectoryInfo Directory = new DirectoryInfo(folderBrowserDialog1.SelectedPath);
                    Directory.MoveTo(folderBrowserDialog1.SelectedPath + WindowSecurity);               
                }
                else
                {
                    DirectoryInfo Directory = new DirectoryInfo(folderBrowserDialog1.SelectedPath);
                    Directory.MoveTo(folderBrowserDialog1.SelectedPath.Substring(0, folderBrowserDialog1.SelectedPath.LastIndexOf(".")));
                }

                }

        }
    }
}

No comments:

Post a Comment