Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Free/Availble Free Disk space - How? 1

Status
Not open for further replies.

IlyaRabyy

Programmer
Nov 9, 2010
571
US
Colleagues,
subject line says it.
I found DriveInfo.TotalFreeSpace and DriveInfo.AvailableFreeSpace in .NET Help, but when I type it in VS 2019's VB code Editor, I get only these options:

2022_08_23_NoFreeDiskSpaceProperty_cqpdix.jpg


Here are my "Imports":
2022_08_23_ImportedAssembies_dba2co.jpg


Everything seems being in place, right? Nevertheless - this:

2022_08_23_NoFreeDiskSpaceProperty_02_wy6n10.jpg


What am I missing?

Regards,

Ilya
 
You need to actually get a drive to be able to examine its properties.

That's essentially what the error message is saying - that it needs an object (a drive object) to be able to execute the method

So, the following should work:

Code:
[COLOR=blue]Dim oDI As DriveInfo
oDI = DriveInfo.GetDrives(0) [COLOR=green]' first drive[/color]
MsgBox("Drive: " & oDI.Name & " Available Free space: " & oDI.AvailableFreeSpace)[/color]

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top