
正文
vb.net文件夹权限 vb60访问文件夹的代码
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
VB.NET 创建文件夹
用Directory.CreateDirectory即可创建文件夹:
' 建立目录
If Not Directory.Exists("C:\负屃\" TextBox1.Text) Then '检查文件夹是否存在
Directory.CreateDirectory("C:\负屃\" TextBox1.Text) '不存在,创建文件建夹
End If
你的例子是因为少了一个"\"引起的,正确的如下:
Dim fsotest As New FileSystemObject
If fsotest.FileExists("C:\负屃\" TextBox1.Text) = False Then
fsotest.CreateFolder("C:\负屃\" TextBox1.Text) '这里你少了一个\
End If
MsgBox("创建成功")
相关问答
Q1: vb.net,如何设置/读取 某用户 对 某文件夹 的访问权限?
不建议用在应用程序中操作共享文件或共享文件夹vb.net文件夹权限,这个东西往往会把软件做得过于死板。
Q2: vb.net 操作文件夹用户权限
'
' 需要添加以下命名空间:
' Imports System.IO
' Imports System.Security.AccessControl
' */
Dim sPath As String = Server.MapPath(文件夹名称字符串)
Directory.CreateDirectory(sPath)
addpathPower(sPath, "ASPNET", "FullControl")
'////////////////////////////////////////////////
Public Sub addpathPower(ByVal pathname As String, ByVal username As String, ByVal power As String)
Dim dirinfo As DirectoryInfo = New DirectoryInfo(pathname)
If (dirinfo.Attributes FileAttributes.ReadOnly) 0 Then
dirinfo.Attributes = FileAttributes.Normal
End If
'取得访问控制列表
Dim dirsecurity As DirectorySecurity = dirinfo.GetAccessControl()
Select Case power
Case "FullControl"
dirsecurity.AddAccessRule(New FileSystemAccessRule(uername,FileSystemRights.FullControl,InheritanceFlags.ContainerInherit,PropagationFlags.InheritOnly,AccessControlType.Allow))
Exit Sub
Case "ReadOnly"
dirsecurity.AddAccessRule(New FileSystemAccessRule(username,FileSystemRights.Read,AccessControlType.Allow))
Exit Sub
Case "Write"
dirsecurity.AddAccessRule(New FileSystemAccessRule(username,FileSystemRights.Write,AccessControlType.Allow))
Exit Sub
Case "Modify"
dirsecurity.AddAccessRule(New FileSystemAccessRule(username,FileSystemRights.Modify,AccessControlType.Allow))
Exit Sub
End Select
dirinfo.SetAccessControl(dirsecurity)
End Sub
Q3: 如图,我用vb.net编写的软件,在本地打开没问题,不过在局域网中打开总是出现权限失败错误
vb.net文件夹权限你试一下把放数据库vb.net文件夹权限的文件夹未知提高权限
Q4: 关于VB.net两个问题 1.按着指定的文件格式删除文件 2.获得某文件或文件夹的权限 要求代码
kill app.path "\**.txt" 删除同级目录的所有txt文本文件
获取文件权限干吗?
结合上面那个删除文件,你是想做一个木马类文件捣乱吧?那就不给你获取权限了,给你个遍历文件权限的,如果你能从代码里举一反三写出获取权限来,算你厉害。
Sub GetFiles(ByVal ParentFolder As String)
Try
Dim sFolders(), sFiles() As String
sFolders = IO.Directory.GetDirectories(ParentFolder)
For Each sFolder As String In sFolders
GetFiles(sFolder)
'Call AddPath("dir", sFolder)
Debug.Print(sFolder)
Application.DoEvents()
Next
sFiles = IO.Directory.GetFiles(ParentFolder)
For Each sFile As String In sFiles
Debug.Print(sFile)
'AddPath("file", sFile)
'lgCount = lgCount + 1
Application.DoEvents()
Next
Catch ex As Exception
End Try
End Sub
关于vb.net文件夹权限和vb60访问文件夹的代码的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。







