Create Sub Directory Using VB.NET

In this article I describe how to create sub-directory using VB.NET.
  • 3772

The Directory.CreateDirectory is also used to create a sub directory. All you have to do is to specify the path of the directory in which this subdirectory will be created in.

The following code snippet creates a Mahesh subdirectory in C:\Temp directory.

Imports System.IO

Module Module1

    Sub Main()

        Dim root As String = "C:\Temp"

        Dim subdir As String = "C:\Temp\Mahesh"

        'If directory does not exist, create it.

        If Not Directory.Exists(root) Then

            Directory.CreateDirectory(root)

        End If

        ' Create sub directory

        If Not Directory.Exists(subdir) Then

            Directory.CreateDirectory(subdir)

        End If

    End Sub

End Module

Output:

 create SubDirectory in vb.jpg

Categories

More Articles

© 2019 DotNetHeaven. All rights reserved.