I'm trying to show the amount of free space on a drive (the C :) but I get the error "Additional information: Object reference not set to an instance of an object".
When I use MessageBox
to show the free space it returns in bytes the value without problems, but when I try to assign the value to a Label
I get the error. The code is as follows:
private void SetMainPage()
{
DriveInfo C = new DriveInfo("C");
espacoHD.Text = C.TotalFreeSpace.ToString();
}