On 27 Dec 2003 13:34:58 +0100,
hi***************@gmx.at (Herfried K.
Wagner [MVP]) wrote:
* dgk <so******************@zero-spam-hotmail.com> scripsit: 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.
As Armin says, that's not the right place for the question.
In .NET 2.0, there will be a 'DriveInfo' class:
<http://longhorn.msdn.microsoft.com/lhsdk/ref/ns/system.io/c/driveinfo/driveinfo.aspx>
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.
;-)
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