EDN Admin
Well-known member
Hi,
I want to be able to take ownership of a folder, but struggling to achieve this.
I can assign a user full control to a folder using:
<pre>Dim FolderPath As String = "C:testmyfolder" [/code]
<pre> Dim UserAccount As String = "domain1testuser" [/code]
<pre>Dim FolderInfo As IO.DirectoryInfo = New IO.DirectoryInfo(FolderPath) [/code]
<pre>Dim FolderAcl As New DirectorySecurity[/code]
<pre> FolderAcl.AddAccessRule(New FileSystemAccessRule(UserAccount, FileSystemRights.FullControl, InheritanceFlags.ContainerInherit Or InheritanceFlags.ObjectInherit, PropagationFlags.None, AccessControlType.Allow))[/code]
<pre> FolderInfo.SetAccessControl(FolderAcl)[/code]
I have tried using FileSystemRights.TakeOwnership but to no avail.
Any assistance is much appreciated.
:O)
I am using Win7 PRO and Visual Studio 2010 PRO
View the full article
I want to be able to take ownership of a folder, but struggling to achieve this.
I can assign a user full control to a folder using:
<pre>Dim FolderPath As String = "C:testmyfolder" [/code]
<pre> Dim UserAccount As String = "domain1testuser" [/code]
<pre>Dim FolderInfo As IO.DirectoryInfo = New IO.DirectoryInfo(FolderPath) [/code]
<pre>Dim FolderAcl As New DirectorySecurity[/code]
<pre> FolderAcl.AddAccessRule(New FileSystemAccessRule(UserAccount, FileSystemRights.FullControl, InheritanceFlags.ContainerInherit Or InheritanceFlags.ObjectInherit, PropagationFlags.None, AccessControlType.Allow))[/code]
<pre> FolderInfo.SetAccessControl(FolderAcl)[/code]
I have tried using FileSystemRights.TakeOwnership but to no avail.
Any assistance is much appreciated.
:O)
I am using Win7 PRO and Visual Studio 2010 PRO
View the full article