Creating Directory or Folder in VB.NET using VB.NET

In this blog we create Directory or Folder on the server. we create a web application in asp.net. we just require the namespace System.IO and a couple lines of code on the page load event.

Imports System.IO

Public Class WebForm1

    Inherits System.Web.UI.Page

 

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        Dim NewDirectory As String = Server.MapPath("Rohatashkumar")

        If Not Directory.Exists(NewDirectory) Then

           

            Directory.CreateDirectory(NewDirectory)

            Response.Write("Directory Created")

        Else

            Response.Write("Directory Exist")

        End If

    End Sub

End Class

 

Now run the application and test it.

 folder1.gif

Figure1