简体   繁体   中英

making the windows directory password protected in C#?

I want to make a directory and all subfolders and files password protected so that no one can access through the Windows Explorer and when he entered the correct password undo the password protected through C# code.

suggest me How to do this and provide sample code if possible.

Thanks in advance.

I would use a password protected zip file.

If you wish to ask for a password and unzip it in C# you could use the popular C# library:

http://www.icsharpcode.net/opensource/sharpziplib/

This question appears to have already been asked.

I'd suggest either using encrypted zips as Derek answered, or if you just want to stop the users from accessing the files without actually encrypting or editing those files, try using CLSIDs in file names to hide folders from windows explorer .

If you'd like to use that method, just add a text file inside the folder with the password in it. When you want to 'unlock' it, just ask for a password, check it against the text file in the folder, delete the textfile and remove the CLSID from the folder's name. Note that it doesn't protect the actual files themselves in any way, just prevents users from accessing it in the conventional ways, which seems to be what your question is asking.

This Link help me a lot in solving this problem.

http://www.codeproject.com/Articles/20880/Folder-protection-for-windows-using-C-Concepts-on

Now I am calling a batch file to rename the folder and undo renaming the folder.

This also explains about how to add to the Right click action of the dir and run through the run command.

Disadvantage here is the CLSID in the XP machine does't support. But in the deployment configuration it will work.

May be this will help.

As I mentioned I don't Want to rename the folder. I am now checking the path with or without the CLSID for accessing the files in it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM