'System.Management.ManagementClass' is not defined

  • Thread starter Thread starter Anil Gupte
  • Start date Start date
A

Anil Gupte

I am getting this error: Type 'System.Management.ManagementClass' is not
defined. The statement is:
Dim diskClass As New System.Management.ManagementClass("Win32_LogicalDisk")


According to the help file, this 'System.Management.ManagementClass' is
under System.Object, so I put in the

Imports System.Object
in namespace, but that seems not to help.

Any suggestions?
Thanx in advance,
 
Anil said:
I am getting this error: Type 'System.Management.ManagementClass' is
not defined. The statement is:
Dim diskClass As New
System.Management.ManagementClass("Win32_LogicalDisk")

You need to add a reference to System.Management.dll, then it'll work.

HTH,
 
As I said it helpd, but raises another question.

What other options are there other than Win32_LogicalDisk? I want only
local Read/Write Disks (I wan tot create a temporary file and I am trying to
find the first disk that has enough space and I can write to).

I did a searh in the help, but came up with nothing. There is some code:
Dim diskClass As New System.Management.ManagementClass("Win32_LogicalDisk")

Dim disks As System.Management.ManagementObjectCollection =
diskClass.GetInstances()

Dim disk As System.Management.ManagementObject

Dim space As System.UInt64

For Each disk In disks

If CStr(disk("Name")) = "C:" Then

space = CType(disk("FreeSpace"), System.UInt64)

End If

Next disk

But this does not help because it is Logical disk. I know there is an
IsLocal property, but I wish there was a more direct way and also, will
IsLocal give me the CD-ROM drive, which obviously I cannot write to.

Thanx in advance,
 
Back
Top