Why no drive object?

  • Thread starter Thread starter dgk
  • Start date Start date
D

dgk

Having searched far and wide in the net classes, and then having
searched far and wide in this newsgroup, it is obvious that there is
no Drive object. We have io.directory objects and a GetLogicalDrives
method, but no way to manipulate the drives returned by
GetLogicalDrives except for Management objects. Logically, shouldn't a
drive object just be part of System.IO? I really don't want to use the
FSO stuff.

This is lots of work just to duplicate the functionality of a
drivebox. Well, I'm sure MS had a good reason do make it so indirect.
Does anyone know what that reason is?
 
dgk said:
Having searched far and wide in the net classes, and then having
searched far and wide in this newsgroup, it is obvious that there
is no Drive object. We have io.directory objects and a
GetLogicalDrives method, but no way to manipulate the drives returned
by GetLogicalDrives except for Management objects. Logically,
shouldn't a drive object just be part of System.IO? I really don't
want to use the FSO stuff.

This is lots of work just to duplicate the functionality of a
drivebox. Well, I'm sure MS had a good reason do make it so
indirect. Does anyone know what that reason is?

I think the question is not related to the VB.NET language. Please post to
one of the Framework groups (microsoft.public.framework[.*]).
 
* dgk said:
Ok. Looks like something they just didn't have time to finish.

ACK. Have a look at the complete class tree, a lot of new classes will
be added which were missing since .NET 1.0.

;-)
 
ACK. Have a look at the complete class tree, a lot of new classes will
be added which were missing since .NET 1.0.

;-)

Just one more thing then. The example in the MSDN library for
Freespace uses FSO and I don't want to. I swiped some of this code
from a previous post of yours and I just cannot figure out how to drop
the drive name or volume or any other property into a listbox. Can you
please tell me what I'm doing wrong? The 1 to Length-1 is intentional,
I'm skipping A: because I didn't want to start off with a removable
drive just in case that was a problem. As is, I'm getting an Invalid
Class error for each drive. I've tried a hundred permutations of this
code.

For i = 1 To Drives.Length - 1
DriveL = "Win32_LogicalDisc.DeviceID=" & Chr(34) &
Drives(i).Substring(0, 2) & Chr(34)
'DriveL = "Win32_LogicalDisc.DeviceID=""C:" & """"
Dim Mydisk As New System.management.ManagementObject(DriveL)
MessageBox.Show("Testing " & Mydisk.Path.ToString) ' this is
just returning DriveL, which is a string. But no error.
Dim diskProperty As System.Management.PropertyData
Try
ListBox1.Items.Add(Mydisk.Properties("FreeSpace").ToString)
'For Each diskProperty In Mydisk.Properties
' ListBox1.Items.Add(diskProperty.Name)
' 'ListBox1.Items.Add(diskProperty.Value)
'Next
' ListBox1.Items.Add(Mydisk.Properties("Name"))
Catch ex As System.Exception
MsgBox("Error is " & ex.Message)
End Try
Next
 
Back
Top