新聞中心
vb.net 創(chuàng)建文件夾和刪除文件夾
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ù),團(tuán)隊從業(yè)經(jīng)驗10年,關(guān)注不同地域、不同群體,并針對不同對象提供差異化的產(chǎn)品和服務(wù);打造開放共贏平臺,與合作伙伴共同營造健康的互聯(lián)網(wǎng)生態(tài)環(huán)境。為烏拉特前企業(yè)提供專業(yè)的成都做網(wǎng)站、網(wǎng)站建設(shè),烏拉特前網(wǎng)站改版等技術(shù)服務(wù)。擁有十多年豐富建站經(jīng)驗和眾多成功案例,為您定制開發(fā)。
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
' 啟動 Windows 資源管理器。
Process.Start("explorer.exe", "D:\")
End Sub
Vb.NET 注冊表 新建目錄樹
Dim Reg As Microsoft.Win32.RegistryKey = Microsoft.Win32.Registry.CurrentUser 'HKEY_CURRENT_USER
Reg.OpenSubKey("\1\2\3\4\5\6\7", True) '在HKEY_CURRENT_USER下新建1\2\3\4\5\6\7的項
希望能對你有所啟發(fā)和幫助。
VB.NET 創(chuàng)建文件夾
用Directory.CreateDirectory即可創(chuàng)建文件夾:
'?建立目錄
If?Not?Directory.Exists("C:\負(fù)屃\"??TextBox1.Text)?Then?'檢查文件夾是否存在
Directory.CreateDirectory("C:\負(fù)屃\"??TextBox1.Text)??'不存在,創(chuàng)建文件建夾
End?If
你的例子是因為少了一個"\"引起的,正確的如下:
Dim?fsotest?As?New?FileSystemObject
If?fsotest.FileExists("C:\負(fù)屃\"??TextBox1.Text)?=?False?Then
fsotest.CreateFolder("C:\負(fù)屃\"??TextBox1.Text) '這里你少了一個\
End?If
MsgBox("創(chuàng)建成功")
怎么利用vb.net創(chuàng)建文件夾
'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("新創(chuàng)建 " b_path " 目錄")
End If
End Sub
End Class
標(biāo)題名稱:vb.net新建目錄,vb 新建文件夾
標(biāo)題URL:http://fisionsoft.com.cn/article/dssoope.html