This tutorial will show you how to create a directory on the disk using ASP.NET 2.0 and C#.NET

The .NET Framework offers a number of types that makes accessing resources on filesystems easy to use.
To write a simple directory to the disk, we will need to first import the System.IO namespace. The System.IO namespace contains the CreateDirectory() method that we will use to create our directory.

We’ll put our code in the btnSubmit_click() event.

When the btnSubmit_Click() event fires it executes the CreateDirectory() method with the specified directory name in txtDir.

We have one textbox, a Submit button, and a label on the front end for user interaction. The front end .aspx page looks something like this:

The flow for the code behind page as follows.

Download Source Files