Private Sub btnRemovePath_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRemovePath.Click
成都創(chuàng)新互聯(lián)專注于冷水江網(wǎng)站建設(shè)服務(wù)及定制,我們擁有豐富的企業(yè)做網(wǎng)站經(jīng)驗(yàn)。 熱誠(chéng)為您提供冷水江營(yíng)銷型網(wǎng)站建設(shè),冷水江網(wǎng)站制作、冷水江網(wǎng)頁設(shè)計(jì)、冷水江網(wǎng)站官網(wǎng)定制、小程序制作服務(wù),打造冷水江網(wǎng)絡(luò)公司原創(chuàng)品牌,更為您提供冷水江網(wǎng)站排名全網(wǎng)營(yíng)銷落地服務(wù)。
Try
' 先建立目錄以便用于后續(xù)的刪除示范。
If Not Directory.Exists("D:\網(wǎng)易") Then
Directory.CreateDirectory(" D:\網(wǎng)易 \Test1")
Directory.CreateDirectory(" D:\網(wǎng)易 \Test2")
Directory.CreateDirectory(" D:\網(wǎng)易 \Test3")
End If
' 刪除子目錄 Test1。
Directory.Delete(" D:\網(wǎng)易 \Test1", True)
' 刪除子目錄 Test2。
Dim myDirectoryInfo As New DirectoryInfo(" D:\網(wǎng)易 \Test2")
myDirectoryInfo.Delete(True)
' 將目錄 C:\AlexDirDemo 及其以下的文件和子目錄全數(shù)刪除。
Directory.Delete(" D:\網(wǎng)易 ", True)
Catch ex As Exception
MessageBox.Show(ex.Message)
Exit Sub
End Try
' 啟動(dòng) Windows 資源管理器。
Process.Start("explorer.exe", "D:\")
End Sub
vb.net使用控件FolderBrowserDialog1,在程序中:
'設(shè)置對(duì)話框中在樹視圖控件上顯示的說明文本
Me.FolderBrowserDialog1.Description = "請(qǐng)選擇輸出報(bào)表所在路徑:"
'設(shè)置從其開始瀏覽的根文件夾
Me.FolderBrowserDialog1.SelectedPath = "c:\"
If Me.FolderBrowserDialog1.ShowDialog() = DialogResult.OK Then
'取得全路徑(包含文件名)
reportPath1 = System.IO.Path.GetFullPath(Me.FolderBrowserDialog1.SelectedPath)
'設(shè)定text顯示文件名
txtReport1.Text = reportPath1
setReportList()
End If
在setReportList()中針對(duì)你所需要的文件進(jìn)行操作等
'
' 需要添加以下命名空間:
' 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
vb.net查看文件夾權(quán)限方法:
1、右鍵單擊獲取權(quán)限的文件夾,轉(zhuǎn)到安全Tab。
2、顯示了這個(gè)文件夾的權(quán)限賬戶。
3、輸入對(duì)應(yīng)賬戶的名稱與密碼即可查看全部權(quán)限信息。