How to get the system drive info?

  • Thread starter Thread starter Victor
  • Start date Start date
V

Victor

Hi guys
I want to get the system drive info programmatically. like which one is hard
disk, which one is a DVD-Rom. But I don't know how to start. Can you guys
please give me some idea how to get these info.

Cheers
 
Victor said:
I want to get the system drive info programmatically. like which one is
hard disk, which one is a DVD-Rom. But I don't know how to start. Can you
guys please give me some idea how to get these info.

If you are using .NET 2.0, check out 'System.IO.Drive'.
 
If you want to get this on all drives in the system and you're using VS
2003, you're going to need:
System.Management:

Private Sub GetDriveProperties()
Dim query As ManagementObjectSearcher = New _
ManagementObjectSearcher("SELECT * From Win32_LogicalDisk ")
Dim queryCollection As ManagementObjectCollection = query.Get()

For Each mo As ManagementObject In queryCollection
Dim pdc As PropertyDataCollection = mo.Properties

' this next line will print to the Console the name of the drive and
its drive type. You can
' deduce from this the types of drive and use those numbers based on
the drives in your system.
' I forget what each drive type number is but you can figure it out.

Console.WriteLine("Name: " & mo("Name").ToString() & ", type: " &
mo.Item("DriveType").ToString())
For Each pd As PropertyData In pdc
Console.WriteLine(pd.Name)
Next
'Console.WriteLine(Integer.Parse(mo("DriveType").ToString()))
Next
End Sub

HTH
Steve
 
Herfried, are you using some special edition of .NET 2.0? I don't even see
that class under System.IO. I see the DriveType enumeration but no Drive
class.

Steve
 
Steve Long said:
Herfried, are you using some special edition of .NET 2.0? I don't even see
that class under System.IO. I see the DriveType enumeration but no Drive
class.

Sorry, it's called 'DriveInfo'.
 
Back
Top