vb.net建立文件夹并给予帐号完全控制权限
Public Shared Sub Create(ByVal user As String, ByVal path As String)
Dim fSec As New DirectorySecurity
My.Computer.FileSystem.CreateDirectory(path)
fSec.AddAccessRule(New FileSystemAccessRule(user, FileSystemRights.FullControl, InheritanceFlags.ContainerInherit, PropagationFlags.InheritOnly, AccessControlType.Allow))
fSec.AddAccessRule(New FileSystemAccessRule(user, FileSystemRights.FullControl, InheritanceFlags.None, PropagationFlags.InheritOnly, AccessControlType.Allow))
fSec.AddAccessRule(New FileSystemAccessRule(user, FileSystemRights.FullControl, InheritanceFlags.ObjectInherit, PropagationFlags.InheritOnly, AccessControlType.Allow))
System.IO.Directory.SetAccessControl(path, fSec)
End Sub
Dim fSec As New DirectorySecurity
My.Computer.FileSystem.CreateDirectory(path)
fSec.AddAccessRule(New FileSystemAccessRule(user, FileSystemRights.FullControl, InheritanceFlags.ContainerInherit, PropagationFlags.InheritOnly, AccessControlType.Allow))
fSec.AddAccessRule(New FileSystemAccessRule(user, FileSystemRights.FullControl, InheritanceFlags.None, PropagationFlags.InheritOnly, AccessControlType.Allow))
fSec.AddAccessRule(New FileSystemAccessRule(user, FileSystemRights.FullControl, InheritanceFlags.ObjectInherit, PropagationFlags.InheritOnly, AccessControlType.Allow))
System.IO.Directory.SetAccessControl(path, fSec)
End Sub