This example is display drive information using DriveInfo Class.

First, you will need to import the System.IO namespace.

The System.IO namespace contains the DriveInfo Class that provides access to information on a drive.This class models a drive and provides methods and properties to query for drive information. Use DriveInfo to determine what drives are available, and what type of drives they are. You can also query to determine the capacity and available free space on the drive.

We use the Page_Load event to provide the list of drives .And use the ListBox1_SelectedIndexChanged event to provide information on a drive.

The code as follows.

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

The flow for the code behind page is as follows.

Download Source Files