C#
// Add namespace System.IO;
DriveInfo[] myDrives = DriveInfo.GetDrives();
foreach (DriveInfo di in myDrives)
{
Console.WriteLine(di.Name);
if (di.IsReady)
{
Console.WriteLine(di.TotalSize);
Console.WriteLine(di.DriveFormat);
Console.WriteLine(di.AvailableFreeSpace);
Console.WriteLine(di.TotalFreeSpace);
Console.WriteLine(di.DriveType);
Console.WriteLine(di.VolumeLabel);
}
}
VB.NET
' Add namespace System.IO;
Dim myDrives() As DriveInfo = DriveInfo.GetDrives()
For Each di As DriveInfo In myDrives
Console.WriteLine(di.Name)
If di.IsReady Then
Console.WriteLine(di.TotalSize)
Console.WriteLine(di.DriveFormat)
Console.WriteLine(di.AvailableFreeSpace)
Console.WriteLine(di.TotalFreeSpace)
Console.WriteLine(di.DriveType)
Console.WriteLine(di.VolumeLabel)
End If
Next di
No comments:
Post a Comment