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.TotalFreeSpace) + " bytes free" + Environment.NewLine;
}
}
}
}
}
/*
run:
C:\ 457,667,014,656.00 bytes free
D:\ 786,328,387,584.00 bytes free
*/