0

我正在 VS2008 中进行部署项目,在安装流程结束时,我需要创建一个共享文件夹,该文件夹具有对可从公司域访问的本地计算机上的每个人的完全控制权限。我成功创建了共享文件夹,但每个人都有读取权限。任何有关如何做到这一点的帮助将不胜感激。

谢谢你,瓦莱里乌

4

1 回答 1

0

我假设您正在使用ManagementClass创建共享文件夹

设置您的访问字段ManagementBaseObject应该让每个人都可以完全控制:

ManagementClass mc = new ManagementClass("win32_share");
ManagementBaseObject inParams = mc.GetMethodParameters("Create");
inParams["Description"] = "Shared Folder";
// ... whathever ...
inParams["Access"] = null; // <-- should give full control access to everyone

如果上述方法不起作用,您可能想尝试使用 smt 显式设置安全级别,如下所示:

    public static void AddDirectorySecurity(string FileName, string Account, FileSystemRights Rights, AccessControlType ControlType)
    {
        DirectoryInfo dInfo = new DirectoryInfo(FileName);

        DirectorySecurity dSecurity = dInfo.GetAccessControl();

        // Add the FileSystemAccessRule to the security settings.  
        dSecurity.AddAccessRule(new FileSystemAccessRule(Account,
                                                         Rights,
                                                         ControlType));
        // Set the new access settings. 
        dInfo.SetAccessControl(dSecurity);
    } 

如果以上都没有帮助,那么我建议您发布您的代码。

于 2009-11-23T15:09:10.617 回答