简体   繁体   English

在目录内创建子目录时访问被拒绝错误

[英]Access denied error while creating sub directory inside the directory

I am facing one problem while creating the subdirectory inside a directory.The error message shown is 'Access to the path 'tempimages' is denied. 我在目录中创建子目录时遇到一个问题。显示的错误消息是'对路径'tempimages'的访问被拒绝。 ' '

I have given full access permission to some of the user accounts in the drive where directory is to be created via application. 我已授予要通过应用程序创建目录的驱动器中某些用户帐户的完全访问权限。

Now in the global.asax i have registered one method which will allow the above user accounts to create a directory.I am able to create parent directory after assigning the access rule for the user accounts. 现在我在global.asax中注册了一种方法,该方法将允许上述用户帐户创建目录。在为用户帐户分配访问规则后,我可以创建父目录。 But when i try to create the subdirectory inside that directory using the same access rules.I get the above error. 但是当我尝试使用相同的访问规则在该目录中创建子目录时,出现上述错误。

        string useraccountForDirectoryCreate = System.Environment.UserDomainName;
        dacl.AddAccessRule(new System.Security.AccessControl.FileSystemAccessRule(useraccountForDirectoryCreate,
        System.Security.AccessControl.FileSystemRights.FullControl,
                System.Security.AccessControl.InheritanceFlags.ContainerInherit |
                System.Security.AccessControl.InheritanceFlags.ObjectInherit,
                System.Security.AccessControl.PropagationFlags.None,
                System.Security.AccessControl.AccessControlType.Allow));
        Directory.CreateDirectory(imageDirectory, dacl);


        Directory.CreateDirectory(tempImageDirectory, dacl);
        DirectoryInfo obj = new DirectoryInfo(imageDirectory);
        obj.CreateSubdirectory(ConfigurationManager.AppSettings["networkStoragePathTemp"].ToString(), dacl);//Access to the path 'tempimages' is denied

I did some search for the above case but to no success, Please help, Thanks S. 我对上述情况做了一些搜索,但没有成功,请帮助,谢谢。

The Error message clearly saying this is happening due to the Permission problem while creating the Sub directory in the Root Directory. 错误消息明确指出,由于在根目录中创建Sub目录时出现权限问题,正在发生这种情况。

If you are using IIS 7.5, try granting the group: IIS_IUSRS access, if the above uses a built in account. 如果您使用的是IIS 7.5,请尝试授予该组:IIS_IUSRS访问权限(如果以上使用内置帐户)。

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

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