This tutorial will show you how to create, delete, move and set attribute to your specified directory and file using System.IO. You will see a sample we created in ASP.NET 2.0 and C#.

First, import the namespace of System.IO.

The System.IO namespace contains the Directory, DirectoryInfo and File Classes.

Directory Class exposes static methods for creating, moving, and enumerating through directories and subdirectories. This class cannot be inherited.

DirectoryInfo Class exposes instance methods for creating, moving, and enumerating through directories and subdirectories. This class cannot be inherited.

File Class Provides static methods for the creation, copying, deletion, moving, and opening of files, and aids in the creation of FileStream objects.

The front end Default.aspx page looks something like this:

Download Source Files