C# DriveInfo AvailableFreeSpace
Description
DriveInfo AvailableFreeSpace
Indicates the amount
of available free space on a drive, in bytes.
Syntax
DriveInfo.AvailableFreeSpace
has the following syntax.
public long AvailableFreeSpace { get; }
Example
Indicates the amount of available free space on a drive, in bytes.
using System;// w w w . jav a 2 s .c o m
using System.IO;
class Test
{
public static void Main()
{
DriveInfo[] allDrives = DriveInfo.GetDrives();
foreach (DriveInfo d in allDrives)
{
Console.WriteLine("Drive {0}", d.Name);
Console.WriteLine(" File type: {0}", d.DriveType);
if (d.IsReady == true)
{
Console.WriteLine(" Volume label: {0}", d.VolumeLabel);
Console.WriteLine(" File system: {0}", d.DriveFormat);
Console.WriteLine(d.AvailableFreeSpace);
Console.WriteLine(d.TotalFreeSpace);
Console.WriteLine(d.TotalSize);
}
}
}
}
The code above generates the following result.