I ran accross this piece of code that uses the System.Management to get the free space on a drive for ONLY logical drives on Hard disks drives. It does this by check the Mediatype. Anybody know where I can find a listing of the Mediatype values? I would like to modify this to get free space only from USB flash drives.Apparently "12" is the Mediatype value for HDDs. Couldn't find anything about this with Google search, but I assume it has to be in MSDN documentation somewhere.Code:Imports System.Management Private Sub frmSysTray_Load(blah blah blah) Dim MGMT As ManagementObject Dim Searcher As ManagementObjectSearcher Searcher = New ManagementObjectSearcher("SELECT * FROM Win32_LogicalDisk") For Each MGMT In Searcher.Get If Convert.ToString(MGMT("MediaType")) = "12" Then MsgBox(MGMT("DeviceID")) MsgBox(Convert.ToString(MGMT("Size"))) MsgBox(Convert.ToString(MGMT("FreeSpace"))) End If Next End Sub


Reply With Quote
