Copy permissions from one Windows Folder to another

只谈情不闲聊 提交于 2019-12-07 07:44:34

问题


I need to create a small C# Windows app which copies security permissions from one folder to another. That includes copying group permissions too. What would be the best way to approach such a challenge?

Yosief Kesete


回答1:


First get out the folder with DirectoryInfo then get out an instance of the DirectorySecurity class using the GetAccessControl method. Then you'll be able to call GetAccessRules and AddAccessRule which should hopefully get you started.




回答2:


Rather than writing the whole thing yourself, why don't you get your app to run a tool like AccessChk (use the -l parameter), and then apply permissions to the target folder based on the info you parse from the output of AccessChk.



来源:https://stackoverflow.com/questions/4323390/copy-permissions-from-one-windows-folder-to-another

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!