Showing posts with label DriveInfo. Show all posts
Showing posts with label DriveInfo. Show all posts

Wednesday, 4 April 2012

You can get Drive info using DriveInfo class.
DriveInfo class available in System.IO Namespace.
You can get details like name, type, size, and status etc... of each drive.
There is one static method GetDrives() of DriveInfo Class.
Syntax :
    DriveInfo.GetDrives();

Here are sample Code for this :
        foreach (DriveInfo objDrive in DriveInfo.GetDrives())
        {
            Response.Write("</br>Drive Type : " + objDrive.Name);
            Response.Write("</br>Drive Type : " + objDrive.DriveType.ToString());
            Response.Write("</br>Available Free Space : " + objDrive.AvailableFreeSpace.ToString() + "(bytes)");
            Response.Write("</br>Drive Format : " + objDrive.DriveFormat);
            Response.Write("</br>Total Free Space : " + objDrive.TotalFreeSpace.ToString() + "(bytes)");
            Response.Write("</br>Total Size : " + objDrive.TotalSize.ToString() + "(bytes)");
            Response.Write("</br>Volume Label : " + objDrive.VolumeLabel);
            Response.Write("</br></br>");

        }