[英]Copy permissions from one Windows Folder to another
I need to create a small C# Windows app which copies security permissions from one folder to another. 我需要创建一个小的C#Windows应用程序,它将安全权限从一个文件夹复制到另一个文件夹。 That includes copying group permissions too.
这也包括复制组权限。 What would be the best way to approach such a challenge?
应对这种挑战的最佳方法是什么?
Yosief Kesete 约瑟夫·基塞特(Yosief Kesete)
而不是自己编写整个内容,为什么不让您的应用运行诸如AccessChk之类的工具(使用-l
参数),然后根据您从AccessChk输出中解析的信息将权限应用于目标文件夹。
First get out the folder with DirectoryInfo then get out an instance of the DirectorySecurity class using the GetAccessControl method. 首先使用DirectoryInfo获取文件夹,然后使用GetAccessControl方法获取DirectorySecurity类的实例。 Then you'll be able to call GetAccessRules and AddAccessRule which should hopefully get you started.
然后,您将能够调用GetAccessRules和AddAccessRule ,它们有望使您入门。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.