2014-01-31 46 views
2

我開始創建一個文件夾的程序
這是我現在有,現在我想要做的是有兩個文本框,一個文本框是目錄和另一個是爲文件夾名稱,我怎麼能在這裏實現?使用vb.net創建文件夾

Private Sub CreateBTN_Click(sender As Object, e As EventArgs) Handles CreateBTN.Click 
    Dim Path As String = txttargerdirectory.Text 
    If Not Directory.Exists(Path) Then 
     Directory.CreateDirectory(Path) 
     MsgBox("folder created") 
    Else 
     MsgBox("Folder already exist") 
    End If 
End Sub 

回答

2

你在找這樣的嗎?

Private Sub CreateBTN_Click(sender As Object, 
          e As EventArgs) Handles CreateBTN.Click 
    Dim sPath As String = IO.Path.Combine(txtPath.Text, txtFolderName.Text) 
    If Not IO.Directory.Exists(sPath) Then 
     IO.Directory.CreateDirectory(sPath) 
     MsgBox("folder created") 
    Else 
     MsgBox("Folder already exist") 
    End If 
End Sub 
+0

是的。它看起來很有希望,我會試試這個,我不知道oi.path.combine,我還在學習先生。 :) –

+0

@LeoElvinLee:沒問題。學習是一條艱難的路,但非常值得,只是不要放棄,隨意提問。 – Neolisk

+0

它的工作原理,非常感謝。 :) –