Saturday 23 July 2011

C# Folder Lock

Last section we discuss about how to move a Folder and also how to rename a folder. Now we going to learn how to Lock the folder, we going to lock the folder WITHOUT any password. In this section we discuss about how to lock but we NOT discuss about how to unlock. So during you want try the program measure you create a new folder and delete it after lock.

Here we need to know what is CLSID. A CLSID is a globally unique identifier that identifies a COM class object. If your server or container allows linking to its embedded objects, you need to register a CLSID for each supported class of objects. msdn 

The CLSID we going to apply is window security {2559A1F2-21D7-11D4-BDAF-00C04F60B9F0}

This is very simple to lock the Folder without any password. We just move the file and rename the file New Folder to New Folder.{2559A1F2-21D7-11D4-BDAF-00C04F60B9F0}. Just add the .{2559A1F2-21D7-11D4-BDAF-00C04F60B9F0} at the back of the folder.

you also can try manually to add this CLSID code at the back of you folder name. The output will lock the folder.

Program 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)
            {
                textBox1.Text = folderBrowserDialog1.SelectedPath;
                DirectoryInfo Directory = new DirectoryInfo(folderBrowserDialog1.SelectedPath);
                Directory.MoveTo(folderBrowserDialog1.SelectedPath + WindowSecurity);
            }
        }
    }
}
 

4 comments:

  1. this is the not good way to protect folder
    if i have folder which size is 10 gb than your code take mor than 1 hour to lock
    please give me a proper way to lock folder

    ReplyDelete
  2. I would like to say that this blog really convinced me to do it! Thanks, very good post. I think this is an informative post and it is very useful and knowledgeable. therefore, I would like to thank you for the efforts you have made in writing this article. Download Free Program For Locking Files For PC - Don't Waste materials Time Looking, Go through About Cellular Desktops On this page password protect folder in xp

    ReplyDelete
  3. PC Locked Folder - Don't Spend Time Browsing, Study Exactly About PC Devices Right here abran

    ReplyDelete
  4. Everything is very open with a really clear description of the challenges. It was truly informative. Your site is extremely helpful. Thank you for sharing!
    Browse this site: How To Really Password Protect Folder

    ReplyDelete