vb.net建立文件夹并给予帐号完全控制权限

 

    Public Shared Sub Create(ByVal user As StringByVal 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
posted @ 2008-11-03 08:39  我想我是风  阅读(745)  评论(0编辑  收藏  举报