2
I am trying to show the amount of free space of a drive (the C:) but I get the error "Additional information: Undefined object reference for an instance of an object".
When I use a MessageBox
to show the free space it returns in bytes the value without problems, but when trying 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();
}
This error clearly indicates that it is null. Your test must be different from this.
– Maniero
So why Messagebox.Show(C.Totalfreespace) manages to return the value?
– davi.in
Either the mistake isn’t there or it’s different, there’s no other way.
– Maniero
If Messagebox works, it’s because
espacoHD
is void.– CypherPotato