Console Application For Reading Disk Space

Sometimes you need to check the disk space of remote windows server , the simple way out for checking this is  what I am going to provide you in this article .

Console Application To Read Disk Space:

  • First create a new Console Application ,  here I have named it as ReadDiskSpace Read Disk Space
  • After creating the application write these simple line of codes.Remember using the References.

using System;
using System.IO;

namespace ReadDiskSpace
{
class Test
{
public static void Main()
{
DriveInfo[] allDrives = DriveInfo.GetDrives();
foreach (DriveInfo d in allDrives)
{
Console.WriteLine("Drive {0}", d.Name);
Console.WriteLine(" Drive type: {0}", d.DriveType);
if (d.IsReady == true)
{
Console.WriteLine(" Volume label: {0}", d.VolumeLabel);
Console.WriteLine(" File system: {0}", d.DriveFormat);
Console.WriteLine(" Available space to current user:{0, 15} bytes",d.AvailableFreeSpace);
Console.WriteLine(" Total available space: {0, 15} bytes",d.TotalFreeSpace);
Convert.ToDecimal(d.TotalFreeSpace);
Console.WriteLine(" Total size of drive: {0, 15} bytes ",d.TotalSize);
      }
    }
  }
}

  • Now its time to run the application,Disk Space

Happy Coding !!!

Leave a Comment

Your email address will not be published.