举个例子:
先引入命名空间:
Imports System.IO
Imports System.Security.AccessControl
代码:
Dim sec As DirectorySecurity = New DirectorySecurity
Dim rule As FileSystemAccessRule = New FileSystemAccessRule("Administrator", FileSystemRights.Delete, AccessControlType.Allow)
sec.AddAccessRule(rule)
Directory.CreateDirectory("C:\test", sec)
这段代码就是以 Administrator 帐户 在 C:\ 创建 test 文件夹。