Directory.CreateDirectory(Path,DirectorySecurity)
第二个参数怎么设置?
vb.net创建文件夹怎么赋权限
答案:2 悬赏:10 手机版
解决时间 2021-03-20 23:08
- 提问者网友:wodetian
- 2021-03-20 11:55
最佳答案
- 五星知识达人网友:長槍戰八方
- 2021-03-20 12:44
举个例子:
先引入命名空间:
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 文件夹。
先引入命名空间:
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 文件夹。
全部回答
- 1楼网友:迟山
- 2021-03-20 12:52
'vb.net2008
imports system.io
public class form1
private sub form1_load(byval sender as system.object, byval e as system.eventargs) handles mybase.load
dim b_path as string
b_path = "d:\123"
if directory.exists(b_path) = true then
msgbox("已有 " & b_path & " 目录")
else
directory.createdirectory(b_path)
msgbox("新创建 " & b_path & " 目录")
end if
end sub
end class
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯