Leo Elvin Lee
Leo Elvin Lee

Reputation: 189

Creating folders using vb.net

I'm starting on a program that creates a folder
this is what i currently have, now what i want to do is to have two textboxes, one textbox is for the directory and the other is for the folder name, how can i implement that here?

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

Upvotes: 3

Views: 3998

Answers (1)

Victor Zakharov
Victor Zakharov

Reputation: 26424

Are you looking for something like this?

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

Upvotes: 4

Related Questions