简体   繁体   English

使Windows目录密码受C#保护?

[英]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. 我想创建一个目录以及所有受密码保护的子文件夹和文件,以便没有人可以通过Windows资源管理器进行访问,当他输入正确的密码时,请撤消受C#代码保护的密码。

suggest me How to do this and provide sample code if possible. 建议我如何执行此操作,并在可能的情况下提供示例代码。

Thanks in advance. 提前致谢。

I would use a password protected zip file. 我会使用受密码保护的zip文件。

If you wish to ask for a password and unzip it in C# you could use the popular C# library: 如果您希望输入密码并将其解压缩到C#中,则可以使用流行的C#库:

http://www.icsharpcode.net/opensource/sharpziplib/ 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 . 我建议您像Derek回答的那样使用加密的zip,或者如果您只是想阻止用户访问文件而没有实际加密或编辑这些文件,请尝试使用文件名中的CLSID在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. 当您想“解锁”它时,只需输入密码,对照文件夹中的文本文件进行检查,删除该文本文件并从文件夹名称中删除CLSID。 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 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. 这也说明了如何添加到dir的右键单击操作并通过run命令运行。

Disadvantage here is the CLSID in the XP machine does't support. 缺点是XP机器不支持CLSID。 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. 我现在正在检查带有或不带有CLSID的路径,以访问其中的文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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