namespace WinFormsApp1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
DriveInfo[] drives = DriveInfo.GetDrives();
foreach (DriveInfo drive in drives)
{
if (drive.IsReady)
{
textBox2.Text += drive.Name + " " + string.Format("{0:n}", drive.TotalSize) + " bytes" + Environment.NewLine;
}
}
}
}
}
/*
run:
C:\ 999,559,262,208.00 bytes
D:\ 4,000,768,323,584.00 bytes
*/